How to get json object from json array using jquery

Jyotishgher Astrology
By -
0

 

How to get json object from json array using jQuery

using jquery each[^] object
$(document).ready(function () {
           var jsonArray = [{ "Result": "True", "isAdmin": "True", "CustomerCode": "02184", "CompanyCode": "1" }];
           $(jsonArray).each(function (index, item) {

               // each iteration
               var result = item.Result;
               var isAdmin = item.isAdmin;
               var CustomerCode = item.CustomerCode;
               var CompanyCode = item.CompanyCode;
               alert(result + '|' + isAdmin + '|' + CustomerCode + '|' + CompanyCode);
           });

       });


using Javascript
var jsonArray = [{ "Result": "True", "isAdmin": "True", "CustomerCode": "02184", "CompanyCode": "1" }];
     var item = jsonArray[0];  // since there is only one item in the array, have specified the index else you shall use 'for' loop to iterate all the items
     var result = item.Result;
     var isAdmin = item.isAdmin;
     var CustomerCode = item.CustomerCode;
     var CompanyCode = item.CompanyCode;
     alert(result + '|' + isAdmin + '|' + CustomerCode + '|' + CompanyCode);

Post a Comment

0Comments

Post a Comment (0)