0

Please help me to iterate the below array in jquery and get each value .

var data = [{"value":"150000","completion":"10.00","coal":"32.40","local":"144.00","bacs":"35.00","landRegistry":"200.00","solFee":"395.00","vatOnSolFees":79,"stampDuty":1500,"total":2395.4},{"value":"120000","completion":"1.00","coal":"3.40","local":"14.00","bacs":"3.00","landRegistry":"100.00","solFee":"35.00","vatOnSolFees":7,"stampDuty":150,"total":395.4}]; 
2

1 Answer 1

0

Use a jquery each to loop through the elements of the array

 var data = [{"value":"150000","completion":"10.00","coal":"32.40","local":"144.00","bacs":"35.00","landRegistry":"200.00","solFee":"395.00","vatOnSolFees":79,"stampDuty":1500,"total":2395.4},{"value":"120000","completion":"1.00","coal":"3.40","local":"14.00","bacs":"3.00","landRegistry":"100.00","solFee":"35.00","vatOnSolFees":7,"stampDuty":150,"total":395.4}]; $.each(data,function(i,v){ console.log(v.value); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

if you want to loop over the objects add another loop

var data = [{ "value": "150000", "completion": "10.00", "coal": "32.40", "local": "144.00", "bacs": "35.00", "landRegistry": "200.00", "solFee": "395.00", "vatOnSolFees": 79, "stampDuty": 1500, "total": 2395.4 }, { "value": "120000", "completion": "1.00", "coal": "3.40", "local": "14.00", "bacs": "3.00", "landRegistry": "100.00", "solFee": "35.00", "vatOnSolFees": 7, "stampDuty": 150, "total": 395.4 }]; $.each(data, function(i, v) { $.each(v, function(index, value) { console.log(index + ':' + value); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Sign up to request clarification or add additional context in comments.

7 Comments

i tried the above code but i am not able to go inside loop and no error is generated
see the console for errors
Hey i want one more help from u bro i want to add edit and delete button in below code of html table .... I am creating table based on JSON now i want to add two column in the same table Edit and Delete . PLease Help
Please find code Below :
My Json : function CreateTableFromJSON() { var myBooks = [ { "Book ID": "1", "Book Name": "Computer Architecture", "Category": "Computers", "Price": "125.60" }, { "Book ID": "2", "Book Name": "Asp.Net 4 Blue Book", "Category": "Programming", "Price": "56.00" }, ]
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.