title: PHP reading invalid json with json_decode();
body: <p>I have invalid external json data, without double quotes around names.</p>
  
  <p>Example:</p>
  
  <pre><code>{
    data: [
      {
        idx: 0,
        id: "0",
        url: "http://247wallst.com/",
        a: [
          {
            t: "Title",
            u: "http://247wallst.com/2012/07/30/",
            sp: "About"
          }
        ],
        doc_id: "9386093612452939480"
      },
      {
        idx: 1,
        id: "-1"
      }
    ],
    results_per_page: 10,
    total_number_of_news: 76,
    news_per_month: [20, 0, 8, 1, 1, 2, 0, 2, 1, 0, 0, 1, 1, 0, 5, 1, 1, 1, 0, 2, 5, 16, 7, 1],
    result_start_num: 2,
    result_end_num: 2,
    result_total_articles: 76
  }
  </code></pre>
  
  <p>As you see a lot of names like data,idx,id,url and others are not double quoted, so this makes this json invalid.
  How can I make this external json valid? I already tried str_replace, replacing '{' to '{"' and ':' to '":' adding double quotes around unquoted names, but this messes up some already double quoted variables.</p>
  
  <p>How can I make this json valid so I can read this data with PHP json_decode? I'm not very familiar with preg_replace..</p>
  
  <p>Valid json will look like:</p>
  
  <pre><code>{
    "data": [
      {
        "idx": 0,
        "id": "0",
        "url": "http://247wallst.com/",
        "a": [
          {
            "t": "Title",
            "u": "http://247wallst.com/2012/07/30/",
            "sp": "About"
          }
        ],
        "doc_id": "9386093612452939480"
      },
      {
        "idx": 1,
        "id": "-1"
      }
    ],
    "results_per_page": 10,
    "total_number_of_news": 76,
    "news_per_month": [20, 0, 8, 1, 1, 2, 0, 2, 1, 0, 0, 1, 1, 0, 5, 1, 1, 1, 0, 2, 5, 16, 7, 1],
    "result_start_num": 2,
    "result_end_num": 2,
    "result_total_articles": 76
  }
  </code></pre>
  
  <p>Please suggest me some php preg_replace function.</p>
  
  <p>Data source:
  <a href="http://www.google.com/finance/company_news?q=aapl&amp;output=json&amp;start=1&amp;num=1" rel="nofollow">http://www.google.com/finance/company_news?q=aapl&amp;output=json&amp;start=1&amp;num=1</a></p>