Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert JSON to string? [duplicate]

Possible Duplicate:
Convert JS object to JSON string

I have a JSON object in JS, and I would like to convert it to string. Is it a function for this?

Thanks in advance,

like image 889
Danny Fox Avatar asked Apr 22 '12 15:04

Danny Fox


People also ask

How do I convert a JSON to a string?

Use the JavaScript function JSON.stringify() to convert it into a string. const myJSON = JSON.stringify(obj); The result will be a string following the JSON notation.

Can JSON have duplicate fields?

The short answer: Yes but is not recommended.

What is toJSON () in JSON?

toJSON() calls the object's toISOString() method, which returns a string representing the Date object's value. This method is generally intended to, by default, usefully serialize Date objects during JSON serialization, which can then be deserialized using the Date() constructor or Date. parse() as the reviver of JSON.

Can JSON have duplicate keys Python?

python - json. loads allows duplicate keys in a dictionary, overwriting the first value - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.


1 Answers

JSON.stringify()

Convert a value to JSON, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified.

like image 132
Vitalii Petrychuk Avatar answered Oct 07 '22 22:10

Vitalii Petrychuk