zjm1126
zjm1126

Reputation: 35680

How to parse an object to JSON using jQuery?

I know to use eval() to parse JSON to an object, but how do I parse an object to JSON format using JavaScript?

Thanks.

Upvotes: 2

Views: 1424

Answers (2)

Felix Kling
Felix Kling

Reputation: 817228

The newer browsers support JSON.stringify. You can also download and include it yourself.

var json = JSON.stringify(yourObject);

Afaik jQuery does not provide such a method.

Upvotes: 4

Doug Molineux
Doug Molineux

Reputation: 12431

Usually if you have a json and want to access something underneath it you just put a dot, like if the name of your json is msg and you want the location parameter it would be:

msg.location

Upvotes: 0

Related Questions