Link to home
Start Free TrialLog in
Avatar of iulianchira
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
Avatar of MacAnthony
MacAnthony
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of iulianchira
iulianchira

ASKER

JSON is undefined ...
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.
Avatar of hielo
>>JSON is undefined ...
are your sure you put this correctly.
<script src="http://www.json.org/json2.js"></script> 
MacAnthony's example works.

Open in new window

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?
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