【发布时间】:2011-03-05 16:57:45
【问题描述】:
我无法将我的 json 数据导入 jQgrid。我得到一个空网格。我希望有人有解决方案。
json 数据似乎格式不正确。
看起来像这样:
{
"total": "3",
"page": "1",
"records": "71",
"rows": {
"1": {
"id": "1",
"cell": [
1,
" Configuration Method",
"Using traditional Weather Display"
]
},
"2": {
"id": "2",
"cell": [
2,
"CSSprint",
"weather-print-php.css"
]
},
"3": {
"id": "3",
"cell": [
3,
"CSSscreen",
"weather-screen-black-narrow.css"
]
}
}
}
问题在于{"1" after "rows": and the "n" before each new {"id":
应该是"rows":[{"id"}
如果我手动编写 JSon 代码,它就可以工作。
相关的php是:
if($page > 1)
{
$i = $page*30;
}
else
$i = 1;
$rows = array();
$responce['total'] = "$total_pages";
$responce['page'] = "$page";
$responce['records'] = "$count";
foreach ($this->wdConfig as $key=>$value)
{
$responce['rows'][$i]['id'] = "$i";
$responce['rows'][$i] ['cell'] = array($i,$key,$value);
$i++;
}
$this-wdConfig 是一个包含键/值配置对的对象。
json 输出可见于:
http://billhogsett.com/wd/wd2/configToJson.php
我看到了几种可能的方法,但都想不通。
让 jSon 正确格式化(即 jQgrid 所期望的)
配置 jSonReader 来处理我的 jSon
我会尝试报告给我的任何建议。
谢谢。
比尔
【问题讨论】:
标签: php json jqgrid format html-helper