json字符串解析
{"1":{"SID":"1","RDATE":"19","$ROW_NUM$":"0","$TABLE_CODE$":"MG_REMARK","RCONTENT":"223","RUSERID":"12","TYPEBY":"2","RID":"1","$PK_CODE$":"1`2`1","RSTATE":"1","RIP":"123"}},{"5":{"SID":"1","RDATE":"19","$ROW_NUM$":"1","$TABLE_CODE$":"MG_REMARK","RCONTENT":"223","RUSERID":"12","TYPEBY":"2","RID":"5","$PK_CODE$":"5`2`1","RSTATE":"1","RIP":"123"}}
这个json串怎么解析呢,比如我想获得里面的RDATE的值。(其中"1","5"都是从数据库中获取的主键它们都是变化的)
[解决办法]
JSON格式有问题。。
var d = { "1": { "SID": "1", "RDATE": "19", "$ROW_NUM$": "0", "$TABLE_CODE$": "MG_REMARK", "RCONTENT": "223", "RUSERID": "12", "TYPEBY": "2"
, "RID": "1", "$PK_CODE$": "1`2`1", "RSTATE": "1", "RIP": "123"
}
, "5": { "SID": "1", "RDATE": "19", "$ROW_NUM$": "1", "$TABLE_CODE$": "MG_REMARK", "RCONTENT": "223", "RUSERID": "12", "TYPEBY": "2", "RID": "5", "$PK_CODE$": "5`2`1", "RSTATE": "1", "RIP": "123"}
};
var item
for (var k in d) {
item = d[k];
alert(k+"\n"+item.SID)
}