Registry / storage / uber-json-schema-filter

uber-json-schema-filter

JSON →
library2.0.5jsnpmunverified

Recursively filters a JSON document to include only properties defined in a given JSON Schema. Version 2.0.5 is stable but unmaintained. Unlike validators like AJV, this library removes non-schema properties instead of validating. Designed for cases where the schema has fewer keys than the document. Requires Node.js and provides CJS-only exports via require().

npm install uber-json-schema-filter
INSTALL
IMPORT
SIG · UBER-JSON-SCHEMA-F
U
uber-json-schema-filter
storagejavascriptv2.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default filter function
const filter = require('uber-json-schema-filter');
import filter from 'uber-json-schema-filter';
The package exports a single function via CommonJS. ESM import syntax is not supported without bundler help.
TypeScript types
// No types provided; use @ts-ignore or declare module
Package has no TypeScript type definitions. Use a .d.ts file or // @ts-ignore.
Browser usage
const filter = require('uber-json-schema-filter'); // with bundler
const filter = await import('uber-json-schema-filter');
No browser build; bundler (Webpack, Rollup) required for browser usage.

Filters a document to only include properties defined in a JSON Schema, removing extras like 'secret'.

const filter = require('uber-json-schema-filter'); const schema = { type: 'object', properties: { name: { type: 'string' }, email: { type: 'string', format: 'email' }, age: { type: 'integer' } }, required: ['name', 'email'] }; const doc = { name: 'Alice', email: 'alice@example.com', age: 30, secret: 'should be removed' }; const result = filter(schema, doc); console.log(JSON.stringify(result)); // {"name":"Alice","email":"alice@example.com","age":30}
Debug
Known issues
deprecatedFiltering of free-form objects (type: object without properties) removes the entire property.
fix
Define explicit properties in the schema for that object, or accept that the property will be omitted.
affects: >=0.0.0
gotchaThe package does NOT validate the document against the schema; validation must be done separately.
fix
Use a validator like AJV after filtering if validation is required.
affects: >=0.0.0
gotchaPerformance assumes schema has fewer keys than document; reverse case may be slow.
fix
If your document is smaller than the schema, consider another library.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: filter is not a function
Using ES import syntax with the CJS module.
fix
Use const filter = require('uber-json-schema-filter');
Cannot find module 'uber-json-schema-filter'
Package not installed or missing from node_modules.
fix
Run npm install uber-json-schema-filter
undefined is not iterable (cannot read property Symbol(Symbol.iterator))
Passing an array as schema where object is expected.
fix
Ensure the schema parameter is an object with type and properties.
Upgrade
Version history
2.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
Resources
uber-json-schema-filter — npm install uber-json-schema-filter · libregistry