Current JSON package to retrieve info from links

0 votes

I am currently trying to find a WORKING and CURRENT JSON files that would be able to pull JSON info from a link such as

https://api.coinmarketcap.com/v1/ticker/bitcoin/?convert=CAD

With that link when you click on that it will display CURRENT prices for bitcoin.

All the libraries I downloaded for JSON is either fragmented or very out of date by years.

Why hasn’t JSON been standard for JAVA projects? But I digress.

If you click on the above link it displays info on bitcoin. I am only interested in one field and that is "price_cad". Which JSON is most recommended that is current and up-to-date and can achieve the desired results.

I reviewed the Question Parsing JSON in JAVA usng Gson. I found that this was not exactly what I was looking for.

Can someone help me with this?

Sep 6, 2018 in Blockchain by digger
• 26,740 points
452 views

1 answer to this question.

0 votes
public static String btcvalue(){
        String msg = "";
        try {
            URL url = new URL("https://api.coinmarketcap.com/v1/ticker/bitcoin/?convert=CAD");
            System.setProperty("http.agent", "Chrome");
            BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
            String str = "";
            while (null != (str = br.readLine())) {
                msg = msg + str;
            }
            String decodedText = msg;
            String[] parts = decodedText.split("price_cad");
            String[] amnt = parts[1].split(",");
            String[] finn = amnt[0].split(":");
            msg = finn[1].replace("\"", "");
        } catch (Exception ex) {
            ex.printStackTrace();
            msg = "10.000";
        }
        return msg;
    }
answered Sep 6, 2018 by slayer
• 29,350 points

Related Questions In Blockchain

0 votes
1 answer

How to retrieve data from a block to a blockchain?

web3.eth.getTransaction(txHash) will returns transaction details like blockHash, transactionIndex, ...READ MORE

answered Jun 27, 2018 in Blockchain by Perry
• 17,100 points
3,738 views
0 votes
1 answer

How can I retrieve to and from address in transaction directly from blockchain?

The spending conditions, i.e., who is able ...READ MORE

answered Jul 11, 2018 in Blockchain by Shashank
• 10,400 points
1,026 views
0 votes
1 answer

How to retrieve data from an Ethereum Block?

To get transaction details like Block Hash ...READ MORE

answered Jul 19, 2018 in Blockchain by Perry
• 17,100 points
2,523 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,740 points
655 views
+1 vote
1 answer

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

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
1,145 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
1,694 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,234 views
0 votes
1 answer

How to retrieve complete world state of hyperledger?

you can achieve this by iteration process ...READ MORE

answered Jul 5, 2018 in Blockchain by slayer
• 29,350 points
1,199 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP