Json
来源:互联网 发布:手机声音剪辑软件 编辑:程序博客网 时间:2024/06/05 12:06
<!doctype html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body><p>First Name: <span id="fname"> </span></p><SCRIPT TYPE="text/javascript">var employees = [{"firstname":"Bill","LastName":"Gates"},{"firstname":"George","LastName":"Bush"},{"firstname":"Thomas","LastName":"Carter"}];document.getElementById('fname').innerHTML=employees[0].LastName</SCRIPT></body></html>
效果图
Json例题1:JSON.parse();
<!doctype html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body><SCRIPT TYPE="text/javascript">var arr = '{"name":"lisi","age":"24","money":"24K"}'; var arrobject = JSON.parse(arr,null); alert(arrobject.name);</SCRIPT></body></html>
效果图
Json例题2:JSON.parse();
<!doctype html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body><SCRIPT TYPE="text/javascript">var arr = '{"status":"1","data":[{"name":"lisi","age":"24","money":"24K"},{"name":"zhaowu","age":"28","money":"25K"}]}'; var arrobject = JSON.parse(arr,null); alert("name:" + arrobject.data[1].name + ",stauts:" + arrobject.status);</SCRIPT></body></html>
效果图
json:存在json数组和json实体
json实体:{键值对}
json数组:[{},{},{}]
eval:
var json对象=eval('('json数据')');
Json例题3:eval()函数例子
<!doctype html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body><script type="text/javascript">var str = "{name:'张三',age:'12',sex:'男'}"; var json = eval('(' + str + ')'); alert(json.name);</script></body></html>效果图:
JSON.parse() eval() 关系图
0 0
- Json
- JSON
- JSON
- JSON
- json
- JSON
- JSON
- json
- Json
- json
- JSON
- json
- json
- JSON
- json
- JSON
- JSON
- json
- Android 的 BroadcastReceiver
- 一个纸水杯的测试用例设计。
- android 编译c
- 考勤项目(gui)
- 常用的五大bug管理工具的优缺点和下载地址
- Json
- Qt远程控制源代码下载
- 常用的五大bug管理工具的优缺点和下载地址
- 2dx学习笔记-----类型转换(CCstring int string char UTF-8互转)
- jQuery
- 计算“两个整数的最大公约数”程序
- 2014项目二
- 【ObjC那点儿事儿】property和synthesize
- java实现 n阶幻方(奇偶通用)