Merianos Nikos Merianos Nikos - 1 year ago 501
PHP Question

php json_decode error quoted object property name expected

I try to create a script that decoding a simple

string in
and I get the following error:

quoted object property name expected

The string I try to decode is the following:


and the code I use to decoded is the following:

json_decode( $json_string );

I also have try to validate my json string in some online json validators, and the string seems to be fine.

Can someone please help me ?

Do you think the problem exists because of the double quotes ?

Update #1

Definetelly was a debuging issue. I place my experience here just to help other devs may come accross the same issue in the feature:

The problem was that my variable that came with the json string was html encoded so instead of the following string :


my variable came with the following string inside:


The mistake by my side was that I used the
method instead of the
. This had as a result to print out the
in my page.

Answer Source

The json string is valid, and it works. You can add true for the second parameter of json_decode, and you get back an array. Try the following:

$json_string = '{"values":[{"url":"","matches":"http|www|google|com"},{"url":"","matches":"http|www|yahoo|com"}]}';

var_dump(json_decode($json_string, true));

It works for me. enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download