Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to extract latest gold price from this json api?

 
Mathew Hamilton
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The json api link is: https://www.quandl.com/api/v3/datasets/WGC/GOLD_DAILY_AUD.json

I need to extract the latest price from there.

My code so far is as follows:


i can get the latest date like this:


But i want to extract the latest price, can anyone give me advice, the code to do this.

Thanks.
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

You would have to look at the JSON format which is returned from the web site, identify where the gold price is in that JSON data, and write your code accordingly to extract from the right place. People who don't know what the format looks like won't be able to help you with that.

You could post the format here if you need help with deciphering it.
 
Mathew Hamilton
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Welcome to the Ranch!

You would have to look at the JSON format which is returned from the web site, identify where the gold price is in that JSON data, and write your code accordingly to extract from the right place. People who don't know what the format looks like won't be able to help you with that.

You could post the format here if you need help with deciphering it.


Hi thanks for the reply,

the format is as follows:

{"dataset":{"id":6442329,"dataset_code":"GOLD_DAILY_AUD","database_code":"WGC","name":"Gold Prices (Daily) - Currency AUD","description":"aud gold price","refreshed_at":"2016-07-26T18:00:43.492Z","newest_available_date":"2016-07-26","oldest_available_date":"1971-04-01","column_names":["Date","Value"],"frequency":"daily","type":"Time Series","premium":false,"limit":null,"transform":null,"column_index":null,"start_date":"1971-04-01","end_date":"2016-07-26","data":[["2016-07-26",1756.7],["2016-07-25",1758.8]

I need to get the [["2016-07-26",1756.7] from data. What is the code to do this?
 
Ron McLeod
Saloon Keeper
Posts: 1263
131
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a formatted version of the JSON data so that we can more easily see how the data is structured.
...... marks where data was removed.

 
Mathew Hamilton
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to get into the array of the last price data:



Ouput:


I'm getting closer....

I just need to extract the price from here. Anyone know how to do this?
 
Mathew Hamilton
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mathew Hamilton wrote:I managed to get into the array of the last price data:



Ouput:


I'm getting closer....

I just need to extract the price from here. Anyone know how to do this?


added .get(1) and got the last price!

Cheers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!