Unable to parse json data from url : I am working on json data for my project.
Json data is to be fetched from url. 
For http://example.com/q=x  json data is {"X":{"USD":158.47}}  
http://example.com/q=y  json data is {"Y":{"USD":145}}

I have javascript file where I need to store the value (158.47 and 145)vto a variable to output it.

I tried:
1) $.getJSON(url, function(json) {
   const prices=json.$x."USD";

   $(`#${symbol}-price`).text(prices.toLocaleString())

   })
2) SONObject obj = new JSONObject(IOUtils.toString(new URL(url), Charset.forName("UTF-8")));
  JSONObject prices = obj.getJSONObject(x);

But none of them are working.

Pls help.