I need to decode a JSON string in PHP but the thing is that the string has a JSON encoded string as one of the value. Something like that :
{
"key1": "value1",
"key2": "{\"key3\":\"{\\\"key4\\\":\\\"value4\\\"}\"}"
}
I'm trying to use json_decode to parse it into an array but it always fail with the error that the syntax is incorrect. If I put it in any validator you can find online, it says the string is valid. Should I use another method to parse the string?
PS: I am fine with the fact that once decoded, the value of key2 won't be an array but instead a string that I would have to decode again.
Thanks!
'and'was left as it is. That way the\characters would be treated as JSON escape characters and not PHP escape characters. Likely you introduced a new problem in constructing your reduced test case.