0

When I do this in git bash:

curl -XPOST "https://evepraisal.com/appraisal.json?market=jita&raw_textarea=tritanium&persist=no"

I will get a JSON response like this:

{
    "appraisal": {
        "created": 1582333288,
        "kind":" listing",
        "market_name": "jita",
        "totals": {
            "buy": 13.96,
            "sell": 14.62,
            "volume": 0.02
        },
        "items":[
            {
                "name": "tritanium",
                "typeID": 34,
                "typeName": "Tritanium",
                "typeVolume": 0.01,
                "quantity": 2,
                "prices": {
                    "all": {
                        "avg": 7.792728706899779,
                        "max": 6660,
                        "median": 8.49,
                        "min": 0.01,
                        "percentile": 10,
                        "stddev": 11.835529435279334,
                        "volume": 22008301773,
                        "order_count": 78
                    },
                    "buy": {
                        "avg": 4.520566796010778,
                        "max": 6.98,
                        "median": 5,
                        "min": 0.01,
                        "percentile": 6.98,
                        "stddev": 1.2552914981531016,
                        "volume": 3832347488,
                        "order_count": 33
                    },
                    "sell": {
                        "avg": 8.740860647577046,
                        "max": 6660,
                        "median": 8.49,
                        "min": 7.31,
                        "percentile": 7.31,
                        "stddev": 12.927105236235532,
                        "volume": 18175954285,
                        "order_count": 45
                    },
                    "updated": "2020-02-22T00:58:22.615370433Z",
                    "strategy":" orders"
                },
                "meta": {
                }
            }
        ],
        "raw": "tritanium x 2",
        "parser_lines": {
            "listing": [
                0
            ]
        },
        "unparsed": {
        },
        "private": false,
        "price_percentage": 100,
        "live": false,
        "expire_minutes": 21600
    }
}

My question is:
How can I pick up a specific attribute from this JSON response?

Like totals:sell:14.62

My second question is:
How can I do that in Java and put the specific attribute in a variable?

catch23
  • 17,519
  • 42
  • 144
  • 217

1 Answers1

0

Everything depends on what do you exactly need.

  • If just get one value from response just take it from the response with JSONObject.

  • you could create Java's POJO for your response, like ResponseWrapper class. Deserialise the response to Java model. Then you can call something like:

double sell = responseObject.getTotals().getSell();

Additional info:

catch23
  • 17,519
  • 42
  • 144
  • 217