当前位置:   article > 正文

js中如何定义json数据_js定义json

js定义json

1、将json格式的数据转换为json

  1. var lineHead="[";
  2. lineHead+="{'mainType':'party','loginName':'G010000000312502','name':'1'},";
  3. lineHead+="{'mainType':'admin','loginName':'G010070004902510','name':'2'},";
  4. lineHead+="{'mainType':'union','loginName':'G001000001522503','name':'3'},";
  5. lineHead+="{'mainType':'youthLeague','loginName':'G010030007682504','name':'4'},";
  6. lineHead+="{'mainType':'discipline','loginName':'G001000000362505','name':'5'}]";
  7. var json=eval('('+lineHead+')');

2、定义json数据,以及对其进行遍历

  1. var config = {"home":{"":"请选择","home":"主页"},
  2. "kcjj":{"":"请选择","kcjj":"课程简介"},
  3. "kcts":{"":"请选择","kcts":"课程特色","cxd":"创新点"},
  4. "jxdw":{"":"请选择","kcfzr":"课程负责人","zjjs":"主讲教师","jxgg":"教学改革","jycg":"教研成果","jsszdwjgjztsz":"师资队伍结构及整体素质"},
  5. "ktjx":{"":"请选择","jxdg":"教学大纲","xyjc":"选用教材","jxjdb":"教学进度表","ktjxms":"课堂教学模式","jxffysd":"教学方法与手段"},
  6. "sjjx":{"":"请选择","sjjxzds":"实践教学指导书","sjjxdg":"实践教学大纲","sjjxtj":"实践教学条件",
  7. "sjjxms":"实践教学模式","kcsjzds":"课程设计指导书","kcsjdg":"课程设计大纲","sjjxffysd":"时间教学方法与手段"},
  8. "kcjs":{"":"请选择","kcjsygh":"课程建设与规划"},
  9. "jxxg":{"":"请选择","lxpj":"录像评价","xspj":"学生评教","xszp":"学生作品","xnddzpj":"校内督导组评价","xwzjpj":"校外专家评价"},
  10. "zczc":{"":"请选择","xgwj":"相关文件","jpkczp":"精品课程自评"}
  11. };
  12. for(var key in config){
  13. if(key==value){
  14. return config[key];
  15. }
  16. }




本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/585179
推荐阅读
相关标签
  

闽ICP备14008679号