> ## Documentation Index
> Fetch the complete documentation index at: https://flatfileinc-feat-updatereactquickstart.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# @flatfile/plugin-json-extractor

> A plugin for parsing .json files in Flatfile.

<Warning>
  When embedding Flatfile, this plugin should be deployed in a server-side
  listener. [Learn more](/orchestration/listeners#listener-types)
</Warning>

<CardGroup cols={1}>
  <Card title="@flatfile/plugin-json-extractor" icon="download">
    <br />

    The `@flatfile/json-extractor` plugin parses a JSON file and extracts first-level nested objects as Sheets in Flatfile.

    <br />

    <br />

    **Event Type:**<br />`listener.on('file:created')`

    <br />

    **Supported file types:**<br />`.json`
  </Card>
</CardGroup>

## Parameters

<ParamField path="options.chunkSize" default="10_000" type="number" optional>
  The `chunkSize` parameter allows you to specify the quantity of records to in
  each chunk.
</ParamField>

<ParamField path="options.parallel" default="1" type="number" optional>
  The `parallel` parameter allows you to specify the number of chunks to process
  in parallel.
</ParamField>

## API Calls

* `api.files.download`
* `api.files.get`
* `api.files.update`
* `api.jobs.ack`
* `api.jobs.complete`
* `api.jobs.create`
* `api.jobs.fail`
* `api.jobs.update`
* `api.records.insert`
* `api.workbooks.create`

## Imported NPM Packages

* [`@flatfile/api@1.4.9+`](https://www.npmjs.com/package/@flatfile/api)
* [`@flatfile/hooks@1.3.0+`](https://www.npmjs.com/package/@flatfile/hooks)
* [`@flatfile/listener@0.3.15+`](https://www.npmjs.com/package/@flatfile/listener)
* [`@flatfile/util-extractor@0.3.0`](../utils/extractor) provides utility functions for extracting and parsing data from various file formats and sources, streamlining data import processes.

## Usage

Listen for a JSON file to be uploaded to Flatfile. The platform will then extract the file automatically. Once complete, the file will be ready for import in the Files area.

```bash Install
npm i @flatfile/plugin-json-extractor
```

```js import
import { JSONExtractor } from "@flatfile/plugin-json-extractor";
```

```js listener.js
listener.use(JSONExtractor());
```

### Full Example

In this example, the `JSONExtractor` is initialized, and then registered as middleware with the Flatfile listener. When a JSON file is uploaded, the plugin will extract the structured data and process it the extractor's parser.

```javascript
import { JSONExtractor } from "@flatfile/plugin-json-extractor";

// Initialize the JSON extractor
const jsonExtractor = JSONExtractor();

// Register the extractor as a middleware for the Flatfile listener
listener.use(jsonExtractor);

// When a JSON file is uploaded, the data will be extracted and processed using the extractor's parser.
```

See a working example in our [flatfile-docs-kitchen-sink](https://github.com/FlatFilers/flatfile-docs-kitchen-sink/blob/main/typescript/extractors/index.ts) Github repo.

## See the code

<CardGroup cols={2}>
  <Card title="@flatfile/plugin-json-extractor" href="https://github.com/FlatFilers/flatfile-plugins/tree/main/plugins/json-extractor" icon="github" />
</CardGroup>
