<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "TabularData",
  "identifier" : "/documentation/TabularData/DataFrame/init(contentsOfJSONFile:columns:types:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "TabularData"
    ],
    "preciseIdentifier" : "s:11TabularData0B5FrameV18contentsOfJSONFile7columns5types7optionsAC10Foundation3URLV_SaySSGSgSDySSAA8JSONTypeOGAA18JSONReadingOptionsVtKcfc"
  },
  "title" : "init(contentsOfJSONFile:columns:types:options:)"
}
-->

# init(contentsOfJSONFile:columns:types:options:)

Creates a data frame by reading a JSON file.

```
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"},
]
```

> Throws: A `JSONReadingError` instance.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)