Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Leff7's avatar
Level 4

Php - json_decode returns null

I am trying to decode json string that looks like the one below with json_decode php function:

"{id:"1",fields:[{id:"1",value:"asdasd"},{id: "2",value:"asdasd"},{id:"3",value:"asdasd"}]}"

I have tried various options from this question. Like:

$foo = utf8_encode($json_string);
$data = json_decode($foo, true);

Or:

json_decode(str_replace ('\"','"', $json_string), true);

Even with:

json_decode( preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $json_string), true );

But, everything I try I always get null. Why is that?

0 likes
1 reply

Please or to participate in this conversation.