javascript - Parsing JSON nested array using JQuery -
i have api returns following json values string.
"[ ["west baton rouge test hello world", "1"], ["lsu parking \u0026 transportation services", "2"], ["demokljafsk", "3"], ["latest", "19"], ["hello check", "20"], ["dinesh devkota", "21"], ["world", "22"], ["altered value.", "23"], ["dinesh devkota", "24"], ["dinesh devkota", "25"], ["dinesh devkota", "26"], ["dinesh devkota", "27"], ["dinesh devkota", "28"], ["rocking client", "29"], ["west baton rouge", "30"], ["test client", "31"] ]"
i having hard time trying first value of each array jquery , log console following code.
$.get("/controller", function (data) { console.log("data loaded: " + data); (var eachdata in data) { console.log(eachdata[0]); } });
i new json , wonder right way.
don't use for..in
arrays
var data = [ ["west baton rouge test hello world", "1"], ["lsu parking \u0026 transportation services", "2"], ["demokljafsk", "3"], ["latest", "19"], ["hello check", "20"], ["dinesh devkota", "21"], ["world", "22"], ["altered value.", "23"], ["dinesh devkota", "24"], ["dinesh devkota", "25"], ["dinesh devkota", "26"], ["dinesh devkota", "27"], ["dinesh devkota", "28"], ["rocking client", "29"], ["west baton rouge", "30"], ["test client", "31"] ]; (var = 0, len = data.length; < len; i++) { console.log(data[i][0]); } // jquery $.each(data, function (index, value) { console.log(value[0]); })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>