我是编码的初学者,我需要你的帮助。 我试图拥有一个valide json,但我有这个错误:
SyntaxError:JSON.parse:expected','或者'}'}在JSON数据的第6行第35列的对象中的属性值之后
我在我的php文件中试过这个正则表达式:
preg_match_all("/<[\s]*meta[\s]*name='?" . "([^>']*)'?[\s]*" . "content='?([^>']*)'?[\s]*[\/]?[\s]*>/si", $contents, $match);
我的Json给了我那个(参见附图中的图片,看看里面有什么&#34; html&#34;):
`
{ "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/' /" } } }`
有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
在相应字段上使用htmlentities()
函数将引号转换为"
表示形式。
您还可以尝试从addslashes()
转移到"
的{{1}}。