0

I am using the Coingecko API. But I just couldn't parse the data. Sample data is below. Parse each block I want to do.

https://api.coingecko.com/api/v3/exchanges

Sample code I use:

$.getJSON( "https://api.coingecko.com/api/v3/exchanges", function( data ) {
 var objArray = JSON.parse(data);
 console.log(objArray["0"]['id']);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

1
  • 1
    data is already a parsed JSON object. It is not required to parse it again. You may directly access as data[0].id Commented Apr 29, 2021 at 13:51

1 Answer 1

3

Basically you don't need to do anything

$.getJSON( "https://api.coingecko.com/api/v3/exchanges", function( data ) {
 console.log(data[0].id);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

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

1 Comment

thanks you for comment. Problem is solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.