classmethod SFrame.read_json(url, orient='records')

Reads a JSON file representing a table into an SFrame.

Parameters: url : string Location of the CSV file or directory to load. If URL is a directory or a “glob” pattern, all matching files will be loaded. orient : string, optional. Either “records” or “lines” If orient=”records” the file is expected to contain a single JSON array, where each array element is a dictionary. If orient=”lines”, the file is expected to contain a JSON element per line.

Examples

The orient parameter describes the expected input format of the JSON file.

If orient=”records”, the JSON file is expected to contain a single JSON Array where each array element is a dictionary describing the row. For instance:

>>> !cat input.json
[{'a':1,'b':1}, {'a':2,'b':2}, {'a':3,'b':3}]
Columns:
a       int
b       int
Rows: 3
Data:
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+---+---+


If orient=”lines”, the JSON file is expected to contain a JSON element per line. If each line contains a dictionary, it is automatically unpacked.

>>> !cat input.json
{'a':1,'b':1}
{'a':2,'b':2}
{'a':3,'b':3}
Columns:
a       int
b       int
Rows: 3
Data:
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+---+---+


If the lines are not dictionaries, the original format is maintained.

>>> !cat input.json
['a','b','c']
['d','e','f']
['g','h','i']
[1,2,3]