Parse a nested JSON file

User 2013 | 8/15/2015, 11:06:12 PM

I read the post which can parse json with sFrame.readcsv and sFrame. unpack as follows.

But I found it seems it could not parse a nested json file like

Before I used json.load and it could parse well. Is there some way to do as json.load for graphLab?



User 1359 | 8/17/2015, 4:34:16 PM

Hi Cong,

SFrame requires loading a table-like data structure, while the JSON in that file includes two attributes (instrument and granularity) with single values. If you want to load the data in 'candles', try this:

` import graphlab as gl import json

file = open('test.json') jsonobj= json.load(file) sa = gl.SArray(jsonobj['candles']) sf = sa.unpack(columnnameprefix=None) `

User 3875 | 3/22/2016, 4:57:32 AM

TypeError Traceback (most recent call last) <ipython-input-39-afe9e542e427> in <module>() 4 file = open('customers.json') 5 jsonobj= json.load(file) ----> 6 sa = gl.SArray(jsonobj['candles']) 7 sf = sa.unpack(columnnameprefix=None)

TypeError: list indices must be integers, not str

I wasn't able to parse nested json file.