Loop and get key/value pair for JSON array using jQuery

后端 未结 6 563
醉话见心
醉话见心 2020-11-29 23:31

I\'m looking to loop through a JSON array and display the key and value.

It should be a simplified version of the following post, but I don\'t seem to have the syn

6条回答
  •  广开言路
    2020-11-30 00:05

    You can get the values directly in case of one array like this:

    var resultJSON = '{"FirstName":"John","LastName":"Doe","Email":"johndoe@johndoe.com","Phone":"123 dead drive"}';
    var result = $.parseJSON(resultJSON);
    result['FirstName']; // return 'John'
    result['LastName'];  // return ''Doe'
    result['Email']; // return 'johndoe@johndoe.com'
    result['Phone'];  // return '123'
    

提交回复
热议问题