Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Extract value from JSONArray in Javascript

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 178
    Comment on it

    Hello Guys,

    I will explain that how to extract values from JSONArray String in Javascript.

    For example we have this jsonarray string below:

    var jsonarraystr ='[{
                "city": "Jaipur",
                "state": "Rajasthan",
    
            },
          {
                "city": "Ahmedabad",
                "state": "Gujrat",
    
            },
            {
                "city": "Delhi",
                "state": "New Delhi",
    
            }]';
    

    jsonarraystr is javascript variable which have JsonArray String.

    Now, we extract values from jsonarraystr variable using below javascript code :

    var jsonarray =  JSON.parse(jsonarraystr);
    
                 for(var i=0;i< jsonarray.length;i++)
             { 
                var city = jsonarray[i].city;
               var state = jsonarray[i].state;
            }
    

    Thanks

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: