简体   繁体   中英

JSON ,retrieval from string

So i am working on a REACT app for school and i have a problem with data passing from page to page. I have managed to send the object as a JSON string and the code for getting the string from local storage looks like this

let show=JSON.parse(localStorage.getItem("SEARCHED_SHOW"))
console.log(show)

and the ouput on the console looks like this


{"id":18,"name":"Steins;Gate","image":"nou","no_episodes":25,"description":"a new show","overall_score":0.0,"caracters":[{"id":22,"name":"Okabe","image":"none","description":"new","no_marks":0,"overall_mark":0.0,"shows":null},{"id":32,"name":"Kurisu","image":null,"description":null,"no_marks":0,"overall_mark":0.0,"shows":null}],"reviews":[],"categories":[{"id":40,"name":"SciFi","image":"none","shows":null}]}

My question is how can i show parts of the object on the page for example i want to show the object id and the string would give me 18

You can get the value of id by show.id

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM