Page 1 of 1
Need help with decoding malformed JSON missing double quotes
Posted: Mon Oct 18, 2010 7:06 pm
by zeus1
I have malformed JSON; it is missing double quotes for every entry. Is there a way to decode it as is, or a function I can use to add double quotes to every entry efficiently?
Re: Need help with decoding malformed JSON missing double qu
Posted: Mon Oct 18, 2010 7:11 pm
by Eran
Hi Zeus, please use [syntax] tags in the future to prevent a very large scroll to the page.
Regarding your question, how did you generate this JSON string? if you are using PHP you can use the json_encode() function that will correctly prepare your data as valid json.
http://php.net/manual/en/function.json-encode.php
Re: Need help with decoding malformed JSON missing double qu
Posted: Mon Oct 18, 2010 7:26 pm
by zeus1
Sorry about that. It's from another source.
Re: Need help with decoding malformed JSON missing double qu
Posted: Mon Oct 18, 2010 7:56 pm
by Eran
You can use the PEAR package Service_Json to clean up your string. Decode the string and then encode it again and it will create a valid JSON string.
http://pear.php.net/pepr/pepr-proposal-show.php?id=198
Re: Need help with decoding malformed JSON missing double qu
Posted: Mon Oct 18, 2010 9:29 pm
by zeus1
***SOLVED***
Thanks, Eran!