如何从JavaScript中的JSON字符串中获取特定值?

时间:2015-08-02 16:23:47

标签: javascript json

我有一个名为page.cat.lastResponseText的JavaScript对象。

此对象具有以下字符串值:

{
    "orderBy":"",
    "orderDesc":false,
    "rows":[
        {"catIndId":"3","indId":"1","catId":"2"},         
        {"catIndId":"4","indId":"4","catId":"2"}
    ],
    "totalResults":2,
    "totalPages":1,
    "pageSize":2,
    "currentPage":1
}

如何将此字符串转换为JSON对象?然后我如何获取对象的值,例如 cat.rows cat.totalResults

1 个答案:

答案 0 :(得分:1)

只需使用JSON.stringify() and JSON.parse()

即可

http://caniuse.com/#feat=json

相关问题