I create website to buy and sell cars. I used Edmunds API to get car information.
I tried to parse information into drop list from their API site as JSON format but I did not get result . I do not how to get information from nested arrays how to get name, nickName , year (in the image)?
enter code here
<!DOCTYPE html>
<html>
<body>
<h1>Customers</h1>
<select id="dd"></select>
<script>
var xmlhttp = new XMLHttpRequest();
var url = "https://api.edmunds.com/api/vehicle/v2/makes?state=used&year=2014&view=basic&fmt=json&api_key=xxxxxxxxxxxxxxxxxxxxxxxxxx";
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
myFunction(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(response) {
var items = JSON.parse(response);
var i;
var out = "<table>";
function addOptions(){
JSONObject object = new JSONObject();
var jsonArray = object.getJSONArray("url");
for (var i = 0; i < jsonArray.length; i++) {
option = document.createElement('option');
option.text = jsonArray.makes[0].name;
select.add(option);
}
</script>
</body>
</html>