Skip to content

Commit

Permalink
feat: add multisheet extraction to JSON extractor (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbrugger authored Nov 7, 2024
1 parent fe21d6e commit 25836cc
Show file tree
Hide file tree
Showing 7 changed files with 343 additions and 155 deletions.
5 changes: 5 additions & 0 deletions .changeset/slow-bottles-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@flatfile/plugin-json-extractor': minor
---

This release introduces multi-sheet extraction to the JSON extractor plugin.
2 changes: 2 additions & 0 deletions flatfilers/sandbox/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { FlatfileListener } from '@flatfile/listener'
import { exportDelimitedZip } from '@flatfile/plugin-export-delimited-zip'
import { JSONExtractor } from '@flatfile/plugin-json-extractor'
import { configureSpace } from '@flatfile/plugin-space-configure'

export default async function (listener: FlatfileListener) {
listener.use(JSONExtractor())
listener.use(
exportDelimitedZip({
job: 'export-delimited-zip',
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions plugins/json-extractor/ref/test-multisheet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"contacts": [
{
"First Name": "Tony",
"Last Name": "Lamb",
"Email": "[email protected]",
"Address": {
"Street": "123 Main Street",
"City": "Springfield",
"State": "ST",
"Zip": "12345",
"Coordinates": {
"Latitude": "40.7128° N",
"Longitude": "74.0060° W"
}
}
},
{
"First Name": "Christian",
"Last Name": "Ramos",
"Email": "[email protected]",
"Address": {
"Street": "456 Elm Street",
"City": "Greenville",
"State": "GT",
"Zip": "67890",
"Coordinates": {
"Latitude": "40.7128° N",
"Longitude": "74.0060° W"
}
}
},
{
"First Name": "Frederick",
"Last Name": "Boyd",
"Email": "[email protected]",
"Address": {
"Street": "789 Oak Street",
"City": "Rivertown",
"State": "RT",
"Zip": "10112",
"Coordinates": {
"Latitude": "40.7128° N",
"Longitude": "74.0060° W"
}
}
}
],
"orders": [
{
"ID": "1234",
"Amount": 5678
},
{
"ID": "9876",
"Amount": 5432
}
]
}
6 changes: 4 additions & 2 deletions plugins/json-extractor/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Extractor } from '@flatfile/util-extractor'
import { parseBuffer } from './parser'

export const JSONExtractor = (options?: {
export interface PluginOptions {
chunkSize?: number
parallel?: number
debug?: boolean
}) => {
}

export const JSONExtractor = (options?: PluginOptions) => {
return Extractor('.json', 'json', parseBuffer, options)
}

Expand Down
Loading

0 comments on commit 25836cc

Please sign in to comment.