Need help with decoding malformed JSON missing double quotes
Moderator: General Moderators
Need help with decoding malformed JSON missing double quotes
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?
Last edited by zeus1 on Mon Oct 18, 2010 9:48 pm, edited 2 times in total.
Re: Need help with decoding malformed JSON missing double qu
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
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
Sorry about that. It's from another source.
Last edited by zeus1 on Mon Oct 18, 2010 9:30 pm, edited 1 time in total.
Re: Need help with decoding malformed JSON missing double qu
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
http://pear.php.net/pepr/pepr-proposal-show.php?id=198
Re: Need help with decoding malformed JSON missing double qu
***SOLVED***
Thanks, Eran!
Thanks, Eran!