0
votes

I'm a beginner in coding and i need your help. I'm trying to have a valide json but i have this error :

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

I tried this regex in my php file: preg_match_all("/<[\s]*meta[\s]*name='?" . "([^>']*)'?[\s]*" . "content='?([^>']*)'?[\s]*[\/]?[\s]*>/si", $contents, $match);

And my Json give me that (see the pic in attach to see what's inside "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

Can someone help me to solve that please ?

1
What are you trying to do? Get the values from the Json? - Kishor
take a look at the following: php.net/manual/en/ref.json.php - Jelmergu
the json in the image has unescaped quotes and is not valid meta\nname="viewport".... - bansi
@kishor : I am trying to get a valid Json and i don't know how to do it. - bricabrac

1 Answers

1
votes

Use htmlentities() function on the appropriate fields to convert the quotationmarks to their &quot; representation.

You can also try addslashes() which escapes from " to \".