fairly new to Javascript, but I have been trying to figure out this parsing issue for several days now and I can't seem to put my finger on what is going on. What I would like to do is get this JSON object into an array or a list of strings into Javascript so that I can use them in my code.
I have a JSON object that I am getting using this URL:
https://min-api.cryptocompare.com/data/all/coinlist
So, I am using the following to grab that object from the URL:
$.getJSON(URL, function(json){
});
to verify that this is indeed a JSON object, I used this which returned "Function Object()"
alert(json.constructor);
So at this point, I have a JSON object inside the variable "json," I would like to start accessing some of the elements. So I try the following:
alert(JSON.stringify(json.Data));
This gives me a popup with all the text from the Data element inside this JSON object, which is great, but I am trying to access the individual items inside "Data." So I try the following which I found here: Accessing JSON elements from javascript :
alert(JSON.stringify(json.Data[1])); AND alert(JSON.stringify(json[1].Data));
Which gets me an "undefined" response. I've then tried turning the "Data" part of this Object into it's own object by using the following:
var DataObj = JSON.parse(json.Data);
console.log(DataObj["Id"]);
But that gives me a "Unexpected token o in JSON at position 1" error.
So I am not sure how to access this Data. I have literally been looking for answers for days and I hate to post what I think is a very amateur question on here but I can't seem to find the answer anywhere online.
Thank you for any help.