{"library":"node-json-transform","title":"JSON Transformation Utility","description":"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.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install node-json-transform"],"cli":null},"imports":["const { transform } = require('node-json-transform');","const { transformAsync } = require('node-json-transform');","const jsonTransform = require('node-json-transform');\nconst result = jsonTransform.transform(data, map);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const { transform, transformAsync } = require('node-json-transform');\n\nconst data = {\n  title : 'title1',\n  description: 'description1',\n  blog: 'This is a blog.',\n  date: '11/4/2013',\n  extra : {\n    link : 'http://goo.cm'\n  },\n  list1:[\n    {\n      name:'mike'\n    }\n  ],\n  clearMe: 'text'\n};\n\nconst map = {\n  item: {\n    name: 'title',\n    info: 'description',\n    text: 'blog',\n    date: 'date',\n    link: 'extra.link',\n    item: 'list1.0.name',\n    clearMe: '', // Clears the attribute\n    fieldGroup: ['title', 'extra'] // Creates an array from specified fields\n  },\n  operate: [\n    {\n      run: 'Date.parse', on: 'date' // Runs Date.parse on the 'date' field\n    },\n    {\n     run: function(val) { return val + ' more info'}, on: 'info' // Custom function on 'info'\n    }\n  ],\n  each: function(item){ // Runs after mapping and operations on each item\n    item.iterated = true;\n    return item;\n  }\n};\n\n// Synchronous transformation\nconst syncResult = transform(data, map);\nconsole.log('Synchronous Result:', JSON.stringify(syncResult, null, 2));\n\n// Asynchronous transformation\ntransformAsync(data, map).then(asyncResult => {\n  console.log('Asynchronous Result:', JSON.stringify(asyncResult, null, 2));\n});\n","lang":"javascript","description":"This quickstart demonstrates both synchronous and asynchronous JSON transformations, including remapping fields, applying built-in and custom functions, and iterating over each transformed item.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}