获取Json对象的值

时间:2016-06-21 01:49:55

标签: jquery json

我有一个JSon的对象类型 例如:

[{"RowError":"","RowState":2,"Table":[{"ID":"1","item":"2","cate":"tran","sTITLE":"translation"},{"ID":"2","item":"3","cate":"tran1","sTITLE":"translation1"}]

如何在对象中获得“表格”?感谢

2 个答案:

答案 0 :(得分:1)

你在json的最后一个错过了}]。尝试以下。



var model = [{"RowError":"","RowState":2,"Table":[{"ID":"1","item":"2","cate":"tran","sTITLE":"translation"},{"ID":"2","item":"3","cate":"tran1","sTITLE":"translation1"}]}];
var table = model[0].Table;
console.log(table);




答案 1 :(得分:-1)

你的JSon不是一个错过大括号的有效者

[
    {
        "RowError": "",
        "RowState": 2,
        "Table": [
            {
                "ID": "1",
                "item": "2",
                "cate": "tran",
                "sTITLE": "translation"
            },
            {
                "ID": "2",
                "item": "3",
                "cate": "tran1",
                "sTITLE": "translation1"
            }
        ]
    }
]

更正JSON

var Jsonob = [
    {
        "RowError": "",
        "RowState": 2,
        "Table": [
            {
                "ID": "1",
                "item": "2",
                "cate": "tran",
                "sTITLE": "translation"
            },
            {
                "ID": "2",
                "item": "3",
                "cate": "tran1",
                "sTITLE": "translation1"
            }
        ]
    }
]
console.log(Jsonob[0].Table)