How does js get the specific value in json format

the json object passed from the previous page is (I don"t know why there are a lot of "", unsolved)

"{" img ": [" _ doc/uniapp_temp/compressed/1543388247982.jpg "]," time ":" 2018-11-28 "," title ":"} "

question: if you want the for loop to get the specific value of img,title,time, how to do it? when you print out i.img, you report a undefiend error, how do you get it?

Dec.21,2021

after getting the json string, parse it with JSON.parse (value in json format), and then traverse

clipboard.png


delete the quotation marks at the beginning and end of the 'json', leaving behind the json object


you have a problematic format
"change the outer double quotation marks to''or the inner key value" to'


.

to ensure unexpected problems, I recommend you

:
 A
 B
When the

A page wants to pass the json object to the B page, first JSON.stringify it (the JSON data you want to pass); this step looks like you have realized that the
B page receives using JSON.parse (received Json data)
for example, if you want to get the value of time (if it is an object, go to the example you gave above)
directly data.time it?
for example, if you want to get the value of time (if it is an object, there are many objects under the array of examples you gave above)
suppose our data is like this

let arr = [
    {"img":["_doc/uniapp_temp/compressed/1543388247982.jpg"],"time":"2018-11-28","title":""},
    {"img":["_doc/uniapp_temp/compressed/1543388247982.jpg"],"time":"2018-11-28","title":""},
    {"img":["_doc/uniapp_temp/compressed/1543388247982.jpg"],"time":"2018-11-28","title":""},
];
 arr.map((item)=>{console.log(item.time)})

JSON.parse (str)

Menu