init(jsonData:columns:types:options:)
Creates a data frame by converting JSON data.
Declaration
init(jsonData data: Data, columns: [String]? = nil, types: [String : JSONType] = [:], options: JSONReadingOptions = .init()) throwsParameters
- data:
The contents of a JSON file as data.
- columns:
An array of column names; Set to
nilto use every column in the JSON file. - types:
A dictionary of column names and their JSON types. The data frame infers the types for column names that aren’t in the dictionary.
- options:
The options that instruct how the data frame reads the JSON file.
Discussion
The JSON file should contain a sequence of objects where each object contains a value for every column name. Here’s an example with two columns “id” and “name”:
[
{"id": 1, "name": "foo"},
{"id": 2, "name": "bar"},
]