Skip to content Skip to sidebar Skip to footer

How To Read Data From Nested Json Using Rest Services Url

I am using spring rest .I am getting valid json . { 'userlist':[ { 'id':2, 'email':'waqasrana11@gmail.com', 'password':'$2a$10$41f83Fw

Solution 1:

You should consider userlist in each loop. Like this:

$.each(data.userlist, function(i, contact) {
       $(".data-contacts-js").append(
       "<tr><td>" + contact.id + "</td>" +
       "<td>" + contact.name+ "</td>" +
       "<td>" + contact.email + "</td></tr>");
});

Solution 2:

$.get() return string, you need to parse to JSON

var data = JSON.parse(data)
$.each(data.userlist, function(i, contact) {...

or using $.getJSON() to return as JSON object

$.getJSON("http://localhost:8080/contacts", function(data) {
  $.each(data.userlist, function(i, contact) {

Post a Comment for "How To Read Data From Nested Json Using Rest Services Url"