---
title: "init(contentsOfJSONFile:columns:types:options:)"
framework: tabulardata
role: symbol
role_heading: Initializer
path: "tabulardata/dataframe/init(contentsofjsonfile:columns:types:options:)"
---

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

Creates a data frame by reading a JSON file.

## Declaration

```swift
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

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"}, ] note: A JSONReadingError instance.

## See Also

### Creating a Data Frame from a JSON File

- [init(jsonData:columns:types:options:)](tabulardata/dataframe/init(jsondata:columns:types:options:).md)
- [JSONType](tabulardata/jsontype.md)
- [JSONReadingOptions](tabulardata/jsonreadingoptions.md)
