(java) Questions about API and JSON parsing.

Asked 1 years ago, Updated 1 years ago, 88 views

{ "success": true, "message": null, "code": null, "elapsed": 0.1291, "data": { "CSPA:BTC": { "cspa": 8012.00601685, "cspa_change_24h": -467.52638691, "cspa_change_24h_pct": -5.51, "volume_btc_24h": 634847.37, "volume_usd_24h": 5086400987.27, "updated": 1522132576 } } }

This is the JSON data that comes out when you run the API code.

I want to do JSON parsing

I don't know where to write the code for JSON parsing.

Do you have to do it with a different class in the same package?

Or I wonder if I have to take the class off the main and fill it out.

Also, in order to extract cspa in the data,

        JSONArray bodyArray = (JSONArray) object.get("CSPA:BTC");
        for(int i = 0 ; i < bodyArray.size(); i++) 
        {
            JSONObject data = (JSONObject) bodyArray.get(i);        
            System.out.println(data.get("cspa").toString());
            System.out.println(data.get("cspa_change_24h").toString());
            System.out.println(data.get("cspa_change_24h_pct").toString()); 
        }

Is this the right code?

Learn only what is necessary without learning JAVA.

only what you need through the rule of thumb

As we worked on it

I need your help.

java json api parsing

2022-09-21 19:35

1 Answers

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.