json

json(str) converts the JSON content in the string str into a struct.

Examples

>> s = json('{"country":"Spain","capital":"Madrid","population":"3,141,991"}')

[s:1x1 struct]

>> s#

 country: Spain
 capital: Madrid
 population: 3,141,991
>> dataString = urlread('https://www.quandl.com/api/v3/datasets/EOD/V.json?api_key=7HA_MuZ7-zb1ob37RRYX&start_date=2017-03-10') 

% fetching data from quandl API

dataStruct = json(dataString)

% parses JSON string

dataStruct# dataset: [21x1 struct] >> dataStruct.dataset{1}# id: 1.40324e+07 dataset_code: V database_code: EOD name: Visa Inc. (V) Stock Prices, Dividends and Splits description: [1x874 char] refreshed_at: 2017-03-23T00:50:03.170Z newest_available_date: 2017-03-22 oldest_available_date: 2008-03-19 column_names: [1x13 cell] frequency: daily type: Time Series premium: 1 limit: [0x0 double] transform: [0x0 double] column_index: [0x0 double] start_date: 2017-03-10 end_date: 2017-03-22 data: [1x9 cell] collapse: [0x0 double] order: [0x0 double] database_id: 12910

See also

xml2table | struct