EXT Js中的Json数据读取问题?

时间:2011-08-12 07:42:49

标签: json extjs

2 个答案:

答案 0 :(得分:1)

使用JSONLint我看到您的JSON无效。当它们不属于合法的JSON转义序列(\)时,您必须转义反斜杠(\", \\, \/, \b, \f, \n, \r, \t, \u<4-digit-hex>)。

在这种情况下,post_content的值是非法的,因为它包含\:\#等序列。将其更改为以下内容应解决问题(当然,您必须修复服务器端代码才能正确转义JSON响应)

{
    "items": [
        {
            "id": "671",
            "post_title": "Seche Vite Dry Fast Top Coat",
            "post_content": "<span style=\"color\\: \\#ff0000\\;\"><strong>Roy Recommends:</strong>  Edith, our in-house nail expert, swears by this product.  No manicure or pedicure is complete without adding this top coat as the finishing touch.</span>\u000d\u000a\u000d\u000aSeche Vite™ dry fast top coat is widely acknowledged as the world\\'s finest top coat.  Specially formulated to penetrate through nail lacquer to the base coat forming a single solid coating over the nail plate for a much more durable finish. Guaranteed not to yellow while leaving nails silky, stronger and resistant to chipping and peeling.\u000d\u000a\u000d\u000a&nbsp;",
            "post_excerpt": "",
            "post_status": "publish",
            "post_parent": "0",
            "parent_sort_id": "671",
            "prod_meta_data_key": "_wpsc_product_metadata",
            "category": "Roy Recommends,Nail Care",
            "_wpsc_price": "10",
            "_wpsc_special_price": "0",
            "_wpsc_sku": "",
            "_wpsc_stock": "4",
            "unpublish_when_none_left": "1",
            "weight": 8.5,
            "weight_unit": "ounce",
            "height": "0",
            "height_unit": "in",
            "width": "0       ",
            "width_unit": "in",
            "length": "0",
            "length_unit": "in",
            "local": "0",
            "international": "0",
            "no_shipping": "0"
        }
    ],
    "totalCount": "1"
}

答案 1 :(得分:0)

我在Chrome中尝试过。 Javascript中的eval()只能解析JSON字符串中的以下序列。其他人都很好。

\" \\ \n \r