How do I format single array nested JSON data and print it a browser using AJAX

Viewed 46

I need help in formatting single array nested JSON data and displaying it in a browser. My main issue is picking a single id of an array of data, formatting it, and printing it on a browser.

I have so far succefully print only array using $('#data').html( JSON.stringify(response));, but no idea on how to print or display formatted JSON on a browser.

<div id="data"></div>

<script>
let response = [
    {"person":[{"id":1,"Name":"ben","Location":"uk","History":"Born 1990","Status":"male"}]}
];


$('#data').html( JSON.stringify(response));

</script>

Kindly

1 Answers

can't get your question properly, Are You asking about how to display the data inside the array using an specific id?

if it is the question, then try the below code,

$('#data').html(JSON.stringify(response[0].person[0]))
Related