- <!DOCTYPE html>
- <html>
- <head lang="en">
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <script>
-
-
-
-
- var json = {"name":"拴住","age":18,"arr":[1,2,3]};
- for(var key in json){
- console.log(key);
- console.log(json[key]);
- if(key === "age"){
- json[key] = 20;
- }
- }
- json.性别="男";
- json["爱好"]="lol";
- console.log(json);
-
-
- var json1 = {"name":11,"sex":男,"age":12};
- var jsonStr = JSON.stringify(json1);
-
-
- var json3 = '{"name":11,"sex":男,"age":12}';
- var jsonObj = JSON.parse(json3);
- var json = {
- "age":24,
- "name":"cst"
- };
- json["age"] = 30;
- alert(json.age);
- json["sex"] = "M";
- alert(json.sex);
- <!-- 遍历Json中的数据 -->
- for(var key in json){
- try{
- var value = eval("json['" + key +"']");
- alert(key+"_"+value);
- }catch(e){}
- }
- delete json["age"];
- alert(json.age);
- </body>
- </html>
posted on
2018-02-05 14:34
哓番茄
阅读(
322)
评论()
编辑
收藏
举报