Get specific JSON data value using array from Coin Market Cap API

0 votes

I want to get the symbol and other information using the "name" in my array.

$.getJSON("//api.coinmarketcap.com/v1/ticker/?limit=0", function(data) {

    var crypto = [
      "Ethereum",
      "Ripple",
      "Tron", 
    ];

    // used for array to get length
    var arrayLength = crypto.length;

    for (var i = 0; i < data.length; i++) {

        console.log( data[i].name == crypto[i] );
    }
  });

I've tried to use:

console.log( data[i].name == crypto[i] );

but can't get this to work. As of now it lists everything when I only want to list data from the items in my array.

I want to get the data in the array using the name to retrieve its information from the API.

Oct 8, 2018 in Blockchain by slayer
• 29,170 points
79 views

1 answer to this question.

0 votes

use inArray function.

example:

$.getJSON("//api.coinmarketcap.com/v1/ticker/?limit=0", function(data) {

    var crypto = [
      "Ethereum",
      "Ripple",
      "Tron", 
    ];

    // used for array to get length
    var arrayLength = crypto.length;

    for (var i = 0; i < data.length; i++) {
        if(jQuery.inArray(data[i].name, crypto) !== -1)
            console.log('Finded: ' + data[i].name);
    }
  });
answered Oct 8, 2018 by Omkar
• 67,600 points

Related Questions In Blockchain

0 votes
1 answer

Cant get a specific value in JSON/PHP

Convert the json-string to a php-array and ...READ MORE

answered Sep 11, 2018 in Blockchain by slayer
• 29,170 points
186 views
0 votes
1 answer

How to get value from solidity contract using java?

web3j caters for this very use case. It ...READ MORE

answered Sep 28, 2018 in Blockchain by slayer
• 29,170 points
260 views
0 votes
1 answer

How to get return value from solidity contract?

Once you call a constant function, you ...READ MORE

answered Aug 16, 2018 in Blockchain by slayer
• 29,170 points
522 views
0 votes
1 answer

How to parse Json data from remote server?

Yes, you can do it use the ...READ MORE

answered Aug 17, 2018 in Blockchain by digger
• 26,550 points
40 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
157 views
0 votes
1 answer
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,340 points
82 views
0 votes
1 answer

Ethereum solidity: Unable to get value from another contract

I have faced similar issues when compiling ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,600 points
226 views
0 votes
3 answers