San
San

Reputation: 125

Quote in json data

Hi you can see there's quote before rural management, this is causing problem while json decoding.. how can i retrive this using PHP json_decode?

[{
"employ":{
        "id":"234",
        "name":""rural management"
        },
"pos":{
        "name":"Programme Officer"
        }
}]

Upvotes: 0

Views: 88

Answers (1)

Quentin
Quentin

Reputation: 944008

You can't. The data is not JSON.

You need to make sure the data is in JSON format before passing it to json_decode.

As a quick hack, you could just perform a string substitution and change "" to "\" globally, but that isn't a robust solution. There is something wrong with the underlying JSON generator that you are getting the data from and that needs to be fixed at the source (probably by switching to using a JSON library instead of smashing strings together).

Upvotes: 1

Related Questions