简体   繁体   中英

How could I parse specific JSON data in jQuery, without using $.each

I have a data from server like this

{"hello2": "world2", "hello3": ["world3", "second_world3"], "hello1": "world1"}

And I want console.log() to get only one value : second_world3

Is there any way except using $.each ?

 var json = {"hello2": "world2", "hello3": ["world3", "second_world3"], "hello1": "world1"} alert(json.hello3[1]); 

The question is not really clear, does your object is always in the same format? You can use plain JavaScript for that:

var myObject = {"hello2": "world2", "hello3": ["world3", "second_world3"], "hello1": "world1"};
console.log(myObject.hello3[1]);

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