I have an asynchronous function that returns remote json and stores it in a variable. After that, I try to use JSON.stringify on that variable and display the contents in an alert message to make sure they're a string instead of [object].[object],[object]. Here's the code:
Jsonvar = result.shows;
var jsonstr=JSON.stringify(Jsonvar)
alert(jsonstr + "yay");
It's not displaying anything. If you need even more code let me know. If you have another method to convert the object to a string, let me know.
JSON.stringify(JSON_OBJECT)
will convert a valid JSON object to string.
jsFiddle - check this example
Note : verify if result.shows is a valid JSON object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.