2017-06-01 5 views
0

私はコーディングの初心者ですから、助けが必要です。 私はヴァリデのJSONを持つようにしようとしているが、私はこのエラーを持っている:PHP SyntaxError:JSON.parse:行6のオブジェクトのプロパティ値の後に '、'または '}'が必要です

SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 6 column 35 of the JSON data

私は私のPHPファイルで、この正規表現を試してみました: preg_match_all("/<[\s]*meta[\s]*name='?" . "([^>']*)'?[\s]*" . "content='?([^>']*)'?[\s]*[\/]?[\s]*>/si", $contents, $match);

そして、私のJSONは(添付で写真を見ている私を与えます) "HTML" の内部で何があるか確認してください:

``

{ 
    "CMS": "tumblr", 
    "title": "Le Blog de Betty - Le Blog de Betty : Blog mode, blog tendances, photos de mode par Betty Autier", 
    "metaTags": { 
     "viewport": { 
      "html": "", 
      "content": "width=device-width,minimum-scale=1,maximum-scale=1" 
     }, 
     "description": { 
      "html": "", 
      "content": "Le Blog de Betty : Blog mode, blog tendances, photos de mode par Betty Autier" 
     }, 
     "generator": { 
      "html": "", 
      "content": "WPML ver:3.1.8.3 stt:4,1,2,65;0" 
     }, 
     "og:locale": { 
      "html": "", 
      "content": "fr_FR" 
     }, 
     "og:type": { 
      "html": "", 
      "content": "website" 
     }, 
     "og:title": { 
      "html": "", 
      "content": "Le Blog de Betty - Le Blog de Betty : Blog mode, blog tendances, photos de mode par Betty Autier" 
     }, 
     "og:description": { 
      "html": "", 
      "content": "Le Blog de Betty : Blog mode, blog tendances, photos de mode par Betty Autier" 
     }, 
     "og:url": { 
      "html": "", 
      "content": "http://leblogdebetty.com/" 
     }, 
     "og:site_name": { 
      "html": "", 
      "content": "Le Blog de Betty" 
     }, 
     "article:publisher": { 
      "html": "", 
      "content": "http://facebook.com/leblogdebetty" 
     } 
    }, 
    "links": { 
     "shortcut icon": { 
      "html": "", 
      "href": "http://localhost:8888/images/2013/12/favicon.ico" 
     }, 
     "canonical": { 
      "html": "", 
      "href": "http://leblogdebetty.com/" 
     }, 
     "next": { 
      "html": "", 
      "href": "http://leblogdebetty.com/page/2/" 
     }, 
     "publisher": { 
      "html": "", 
      "href": "https://plus.google.com/+leblogdebetty" 
     }, 
     "'dns-prefetch' ": { 
      "html": "", 
      "href": "'//s.w.org' /" 
     }, 
     "stylesheet": { 
      "html": "", 
      "href": "http://leblogdebetty.com/wp-content/plugins/jetpack/css/jetpack.css?ver=3.4.3" 
     }, 
     "'https://api.w.org/' ": { 
      "html": "", 
      "href": "'http://leblogdebetty.com/wp-json/' /" 
     } 
    } 
}

Part of Json file

誰かが私にそれを解決するのを助けることができますか?

+0

あなたは何をしようとしていますか? Jsonから値を取得しますか? – Kishor

+0

次のコードを見てください:http://php.net/manual/en/ref.json.php – Jelmergu

+0

イメージのjsonにはエスケープされていない引用符があり、 'meta \ nname =" viewport "... ' – bansi

答えて

0

適切なフィールドにhtmlentities()関数を使用して、引用符を&quot;表現に変換します。

"から\"にエスケープするaddslashes()を試すこともできます。

関連する問題