JSON对象是否需要正确格式化?

时间:2011-11-10 18:35:45

标签: json

我申请了一份工作,并做了一些测试。它非常简单但我必须处理它们提供的JSON对象,它没有正确格式化。

我想知道这是否正常(我是JSON的新手)或不? (好的意思是我仍然可以将它用作标准的JSON对象)。

这是JSON字符串:

{"title": "Carbon Market Trader EU",
    "link": "cmteu",
    "children": [
      {"title": "Analysis",
        "link": "analysis",
        "children": [
            {"title": "Daily Reports",
                "link": "daily",
                "children": [
                    {"title": "Forward",
                      "link": "fwd",
                          "children": [

                            {"title": "Morning Report", "link": "morning"},
                            {"title": "Benchmark", "link": "bench"}
                        ]}
            ]},
            {"title": "Weekly Reports",
                "link": "weekly",
                "children": [
                    {"title": "Forward",
                    "link": "fwd",
                    "children": [
                        {"title": "Weekly Report","link": "weekly"}
                    ]}
            ]},
            {"title": "Monthly Reports","link": "mth"},
            {"title": "Price Forecasts",
                "link": "pfc",
                "children": [
                    {"title": "Price Forecasts","link": "pfc"},
                    {"title": "Supply and Demand","link": "sad"}
            ]},
            {"title": "Policy Updates","link": "pup"},
            {"title": "Analyst Updates","link": "aup"},
            {"title": "Carbon Market Brief","link": "cmb"},
            {"title": "Report Library","link": "ml"},
            {"title": "Reuters Insider","link": "ri"},
            {"title": "Market Indicators",
                "link": "mi",
                "children": [
                    {"title": "Overview","link": "overview"},
                    {"title": "Breakdown",
                        "link": "breakdown"
                        "children": [
                            {"title": "Cross Commodity Indicators","link": "cci"},
                            {"title": "Technical Indicators","link": "ti"},
                            {"title": "Fundamental Indicators","link": "fi"},
                            {"title": "Information Indicators","link": "ii"}
                    ]}
            ]}
    ]},
    {"title": "Supply",
        "link": "supply",
        "children": [
            {"title": "Cap","link": "cap"},
            {"title": "Overview","link": "overview"},
            {"title": "Reserves","link": "reserves"}
    ]},
    {"title": "Demand",
        "link": "demand",
        "children": [
            {"title": "Emissions Forecast","link": "ef"},
            {"title": "Power and Heat Emissions","link": "phe"},
            {"title": "Industry Emissions","link": "ie"}
    ]},
    {"title": "Market Data",
    "link": "md",
    "children": [
        {"title": "Carbon",
        "link": "carbon",
        "children": [
            {"title": "Forward",
             "link": "fwd",
                "children": [
                    {"title": "EUA","link": "eua"},
                    {"title": "sCER","link": "cer"},
                    {"title": "RGA","link": "rga"}
            ]}
        ]},
        {"title": "Coal",
        "link": "coal",
        "children": [
            {"title": "Forward",
            "link": "fwd",
            "children": [
                {"title": "API-2","link": "api"}
            ]}
        ]},
        {"title": "Crude oil",
        "link": "crude",
        "children": [
            {"title": "Forward",
             "link": "fwd",
            "children": [
                {"title": "Brent","link": "brent"}
            ]}
        ]}
    ]}
]}

2 个答案:

答案 0 :(得分:1)

请使用http://jsonlint.com/

这不行。

答案 1 :(得分:1)

尝试将该对象传递给“eval()” - 它失败了。无效的JSON。 (我必须承认很难确切地知道为什么)