Registry / data / node-json-transform

node-json-transform

JSON →
library1.1.2jsnpmunverified

node-json-transform is a Node.js utility designed for declaratively transforming and performing operations on JSON data structures. Its last stable release is v1.1.2. The project appears to be abandoned, with no significant updates or releases in the past 8 years. It allows users to define a mapping schema to rename, restructure, and apply operations to JSON objects and arrays. Key features include path-based data retrieval (similar to `lodash.get`), custom functions for data manipulation via `operate` and `each` hooks, default value assignment for missing attributes, and specified attribute removal. It offers both synchronous and asynchronous transformation APIs, making it suitable for various data processing scenarios.

npm install node-json-transform
INSTALL
IMPORT
SIG · NODE-JSON-TRANSFOR
N
node-json-transform
datajavascriptv1.1.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

transform
const { transform } = require('node-json-transform');
import { transform } from 'node-json-transform';
This package is CommonJS-only and does not natively support ES Modules. Use `require`.
transformAsync
const { transformAsync } = require('node-json-transform');
import { transformAsync } from 'node-json-transform';
CommonJS-only. The asynchronous version returns a Promise.
All exports (common pattern)
const jsonTransform = require('node-json-transform'); const result = jsonTransform.transform(data, map);
import jsonTransform from 'node-json-transform';
To access both `transform` and `transformAsync`, it's common to require the entire module and access properties.

This quickstart demonstrates both synchronous and asynchronous JSON transformations, including remapping fields, applying built-in and custom functions, and iterating over each transformed item.

const { transform, transformAsync } = require('node-json-transform'); const data = { title : 'title1', description: 'description1', blog: 'This is a blog.', date: '11/4/2013', extra : { link : 'http://goo.cm' }, list1:[ { name:'mike' } ], clearMe: 'text' }; const map = { item: { name: 'title', info: 'description', text: 'blog', date: 'date', link: 'extra.link', item: 'list1.0.name', clearMe: '', // Clears the attribute fieldGroup: ['title', 'extra'] // Creates an array from specified fields }, operate: [ { run: 'Date.parse', on: 'date' // Runs Date.parse on the 'date' field }, { run: function(val) { return val + ' more info'}, on: 'info' // Custom function on 'info' } ], each: function(item){ // Runs after mapping and operations on each item item.iterated = true; return item; } }; // Synchronous transformation const syncResult = transform(data, map); console.log('Synchronous Result:', JSON.stringify(syncResult, null, 2)); // Asynchronous transformation transformAsync(data, map).then(asyncResult => { console.log('Asynchronous Result:', JSON.stringify(asyncResult, null, 2)); });
Debug
Known issues
gotchaThe `node-json-transform` project appears to be abandoned, with no updates or security patches in over 8 years. It is not recommended for new projects or environments requiring active maintenance and security vigilance.
fix
Consider migrating to a more actively maintained JSON transformation library or implement custom transformation logic.
affects: >=1.0.0
gotchaThis package is CommonJS-only and does not provide native ES Module (ESM) support. Attempting to use `import` statements directly will result in errors.
fix
Always use `require()` syntax for importing, e.g., `const { transform } = require('node-json-transform');`.
affects: >=1.0.0
gotchaThe library does not ship with TypeScript type definitions. Users working in TypeScript projects will need to create their own declaration files (`.d.ts`) or use `@ts-ignore` to suppress type errors.
fix
Create a `node-json-transform.d.ts` file with basic type declarations for `transform` and `transformAsync`.
affects: >=1.0.0
gotchaThe `operate` and `each` fields in the map schema allow custom functions to be executed, which can be a security risk if the transformation map is sourced from untrusted user input, as it permits arbitrary code execution.
fix
Sanitize or validate transformation maps thoroughly if they originate from untrusted sources. Avoid directly exposing map creation to end-users.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: transform is not a function
Attempting to import `transform` using ES Module `import` syntax instead of CommonJS `require`.
fix
Change `import { transform } from 'node-json-transform';` to `const { transform } = require('node-json-transform');`.
Error: Cannot find module 'node-json-transform'
The package has not been installed, or there's a typo in the package name during import/require.
fix
Run `npm install node-json-transform` in your project directory.
UnhandledPromiseRejectionWarning: TypeError: transformAsync is not a function
Trying to use `transformAsync` directly without destructuring or accessing it from the required module object.
fix
Ensure `const { transformAsync } = require('node-json-transform');` is used, or access it via `const jsonTransform = require('node-json-transform'); jsonTransform.transformAsync(...)`.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
node-json-transform — npm install node-json-transform · libregistry