Reputation: 8810
as usual I'm working with my messed up database and I found that there are some fuxked up JSON string in the database... Some of the JSON strings are missing the double-quotes around the keys and/or values.
I'm thinking of writing a PHP script to fix that, what recommendations do you guys have about how I can detect the missing quotes and automatically add them? Or there is no such convenient way...
Thanks smart community!
Upvotes: 0
Views: 358
Reputation: 6632
You can use json_decode and json_last_error to detect if there is an error in the string. And then json_encode to write the valid json value back out.
Upvotes: 1