$data = '{
"cols": [ {"id":"","label":"ID","pattern":"","type":"string"},
{"id":"","label":"Instant Background","pattern":"","type":"number"},
{"id":"","label":"Red","pattern":"","type":"number"},
{"id":"","label":"Green","pattern":"","type":"number"},
{"id":"","label":"Blue","pattern":"","type":"number"}
],
"rows": [
{"c":[{"v":"827075"},{"v":3992},{"v":3989},{"v":3994},{"v":3993}]},
{"c":[{"v":"827070"},{"v":3974},{"v":3987},{"v":3985},{"v":3985}]},
{"c":[{"v":"827070"},{"v":3974},{"v":3987},{"v":3985},{"v":3985}]},
{"c":[{"v":"827070"},{"v":3974},{"v":3987},{"v":3985},{"v":3985}]},
{"c":[{"v":"827070"},{"v":3974},{"v":3987},{"v":3985},{"v":3985}]}
]
}'; echo $data;
好的,当以这种格式在谷歌地图上使用时,数据与回声一起工作,所以那里没有问题。
function drawChart(jsonData) {
jsonData = $.ajax({
url: "http://www.mailboxmbe.com/jsongraph.php",
dataType:"json",
async: false
}).responseText;
PHP 从 SQl 语句中获取数据并按如下方式构造数据:
$JSONObject1 = '{"c":[{"v":"'.$row["id"].'"},{"v":'.$row["sinstantBackground"].'},{"v":'.$row["sRed"].'},{"v":'.$row["sGreen"].'},{"v":'.$row["sBlue"].'}]},'.$JSONObject1;
每一行都有以下 id,sinstantBackground,sRed,sGreen.sBlue。
在图形页面上,jsonData保存从通过 SQL 查询调用的 echo $data 传递给它的 json 字符串。
我想做的是研究如何将jsonData中的 json 脚本转换为一种格式,我可以在其中找出最大的 ID 是什么?