Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import a JSON file into MATLAB programatically?

I am trying to load my data from a JSON file into MATLAB that is delimited with ,. The format of my data is as follows:

{"created_at": "Mon Oct 27 20:35:47 +0000 2014", "tweet": "Silver Finished Up, Gold, Copper, Crude Oil, Nat Gas Down - Live Trading News http://t.co/jNLTUIgHwA", "id": 526834668759285761, "sentiment": "negative"}

{"created_at": "Mon Oct 27 20:36:21 +0000 2014", "tweet": "Gold, Silver slips on lacklustre demand- The Economic Times http://t.co/Jd5Tn9ctfX", "id": 526834810300289024, "sentiment": "negative"}

How would I do so?

like image 589
Adam Avatar asked Jul 09 '26 14:07

Adam


1 Answers

As of version 2016b, Matlab has integrated json support.

See: https://www.mathworks.com/help/matlab/ref/jsondecode.html

In short, you do:

jsonData = jsondecode(fileread('file.json'));
like image 183
mousomer Avatar answered Jul 12 '26 05:07

mousomer