0

JSON syntax Error......

See my code , I've given the right commands for JSON to run , but there's a error , I can't Find the Error , can anyone solve my error , I'll be very very thankful , I'm New at JavaScript so don't know much about it , I'm Learning it........?????? Here's My code – https://code.sololearn.com/Wj7WgMY90PIs/?ref=app

20th Jul 2020, 12:24 PM
_Levi_
_Levi_ - avatar
3 Antworten
+ 4
Change to console.log(JSON.stringify(students)) for object to json string conversion Or for json string to object, please check this out https://code.sololearn.com/Wwvmle1GmkPr/?ref=app
20th Jul 2020, 12:29 PM
Calviղ
Calviղ - avatar
+ 4
_K_ The syntax is the problem. let students = { 0:{ "name": "K", "age": "22", "height": 155 }, 1:{ "name": "Qazi", "age": "25", "height": 156 } } console.log(JSON.stringify(students)); The Error is in the console.log(JSON.parse(students)) because you are trying to parse an array. Above is the correct syntax JSON.parse is a function which converts a Json object in string format. check this out 👇 https://code.sololearn.com/W7c42ouSIETh/?ref=app
20th Jul 2020, 12:34 PM
viknesh vikky
viknesh vikky - avatar
+ 1
I'm very very thankful to you all , I'm happy that my problem has been solved and , I have learnt something new.......😁😁😁
20th Jul 2020, 3:38 PM
_Levi_
_Levi_ - avatar