Contents

init(contentsOfJSONFile:columns:types:options:)

Creates a data frame by reading a JSON file.

Declaration

init(contentsOfJSONFile url: URL, columns: [String]? = nil, types: [String : JSONType] = [:], options: JSONReadingOptions = .init()) throws

Parameters

  • url:

    A URL to a JSON file.

  • columns:

    An array of column names; Set to nil to 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"},
]

See Also

Creating a Data Frame from a JSON File