iulianchira
asked on
How can I convert a JSON object to a string representation
I have a JSON object that I've obtained from a string using the eval function. After changing some value I want to convert it back to a string to store it a hidden field. This might be dumb, but I have no idea how to do it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I just tested it in both FF and IE and both worked. Did you just use just this code in a file? Maybe you want to download the json2.js locally and put it with the file and change the path to the local path.
>>JSON is undefined ...
are your sure you put this correctly.
are your sure you put this correctly.
<script src="http://www.json.org/json2.js"></script>
MacAnthony's example works.
ASKER
Is there any other way except using json2.js?
Sure, you could recreate what the 150 lines of the JSON.stringify() method it's associated methods do. That's more time than I would want to spend on it though.
Is there something wrong with using a library created by the group that is in charge of the format?
Is there something wrong with using a library created by the group that is in charge of the format?
ASKER
Not really, that is possibly what we'll end up using. We are however reluctant to using any extra libraries except those inherent to .net 3.5
ASKER