{"id":28936132,"url":"https://github.com/aalfiann/native-json-transform","last_synced_at":"2026-05-07T13:47:36.371Z","repository":{"id":57308262,"uuid":"209773110","full_name":"aalfiann/native-json-transform","owner":"aalfiann","description":"Restructuring and performing operations on JSON on the fly for NodeJS.","archived":false,"fork":false,"pushed_at":"2021-06-01T09:06:28.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-01T11:36:34.582Z","etag":null,"topics":["json","json-transform","nodejs","on-the-fly","transform"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aalfiann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-20T11:17:50.000Z","updated_at":"2024-02-24T09:11:02.000Z","dependencies_parsed_at":"2022-09-07T04:51:39.260Z","dependency_job_id":null,"html_url":"https://github.com/aalfiann/native-json-transform","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/aalfiann/native-json-transform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aalfiann%2Fnative-json-transform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aalfiann%2Fnative-json-transform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aalfiann%2Fnative-json-transform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aalfiann%2Fnative-json-transform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aalfiann","download_url":"https://codeload.github.com/aalfiann/native-json-transform/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aalfiann%2Fnative-json-transform/sbom","scorecard":{"id":158788,"data":{"date":"2025-08-11","repo":{"name":"github.com/aalfiann/native-json-transform","commit":"2e6ca7ab3e546cbc3b60ff45a9f8cac28a3edd68"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/7 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-16T12:44:35.299Z","repository_id":57308262,"created_at":"2025-08-16T12:44:35.299Z","updated_at":"2025-08-16T12:44:35.299Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32740912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","json-transform","nodejs","on-the-fly","transform"],"created_at":"2025-06-22T20:07:45.585Z","updated_at":"2026-05-07T13:47:36.365Z","avatar_url":"https://github.com/aalfiann.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# native-json-transform\n[![NPM](https://nodei.co/npm/native-json-transform.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/native-json-transform/)  \n  \n[![npm version](https://img.shields.io/npm/v/native-json-transform.svg?style=flat-square)](https://www.npmjs.org/package/native-json-transform)\n[![Build Status](https://travis-ci.com/aalfiann/native-json-transform.svg?branch=master)](https://travis-ci.com/aalfiann/native-json-transform)\n[![Coverage Status](https://coveralls.io/repos/github/aalfiann/native-json-transform/badge.svg?branch=master)](https://coveralls.io/github/aalfiann/native-json-transform?branch=master)\n[![Known Vulnerabilities](https://snyk.io//test/github/aalfiann/native-json-transform/badge.svg?targetFile=package.json)](https://snyk.io//test/github/aalfiann/native-json-transform?targetFile=package.json)\n![NPM download/month](https://img.shields.io/npm/dm/native-json-transform.svg)\n![NPM download total](https://img.shields.io/npm/dt/native-json-transform.svg)  \nRestructuring and performing operations on JSON on the fly for NodeJS.\n\n## Background\nThis is a fork version form original [node-json-transform](https://github.com/bozzltron/node-json-transform).  \nThe difference about this with original version is that we already removed `Lodash` dependencies. So this library has no dependencies anymore. That is why we call it `native-json-transform`.\n\n**Note:**\n- Code slightly different with original but all features is same.\n- Minimum requirement `NodeJS 6`.\n\n## Install use NPM\n```bash\n$ npm install native-json-transform\n```\n\n## Usage\n\n### Basic Example\n\n```javascript\nvar JsonTransform = require(\"native-json-transform\").JsonTransform;\n```\n\nFirst we need some data.\n\n```javascript\nvar data = {\n\tposts : [\n\t\t{\n\t\t\ttitle : \"title1\",\n\t\t\tdescription: \"description1\",\n\t\t\tblog: \"This is a blog.\",\n\t\t\tdate: \"11/4/2013\",\n\t\t\textra : {\n\t\t\t\tlink : \"http://goo.cm\"\n\t\t\t},\n\t\t\tlist1:[\n\t\t\t\t{\n\t\t\t\t\tname:\"mike\"\n\t\t\t\t}\n\t\t\t],\n\t\t\tlist2:[\n\t\t\t\t{\n\t\t\t\t\titem: \"thing\"\n\t\t\t\t}\n\t\t\t],\n\t\t\tclearMe: \"text\"\n\t\t}\n\t]\n};\n```\n\nThe map defines how the output will be structured and which operations to run.\n\n```javascript\nvar map = {\n\tlist : 'posts',\n\titem: {\n\t\tname: \"title\",\n\t\tinfo: \"description\",\n\t\ttext: \"blog\",\n\t\tdate: \"date\",\n\t\tlink: \"extra.link\",\n\t\titem: \"list1.0.name\",\n\t\tclearMe: \"\",\n\t\tfieldGroup: ['title', 'extra']\n\t},\n\toperate: [\n\t\t{\n\t\t\trun: \"Date.parse\", on: \"date\"\n\t\t},\n\t\t{\n\t\t\trun: function(val) { return val + \" more info\"}, on: \"info\"\n\t\t}\n\t],\n\teach: function(item){\n\t\t// make changes\n\t\titem.iterated = true;\n\t\treturn item;\n\t}\n}\n};\n```\nYou can read this as follows:\n- Get the array of objects in \"posts\".\n- Map the name to title, info to description etc.\n- Run Data.parse on the date value.\n- Run each function on all items after mapping and operations.\n\nRun it synchronously\n```javascript\nvar jsonTransform = JsonTransform(data, map);\nvar result = jsonTransform.make();\nconsole.log(result);\n```\n... or asynchronously\n```javascript\nvar jsonTransform = JsonTransform(data, map);\nvar promise = jsonTransform.makeAsync();\npromise.then((function(result){\n\tconsole.log(result);\n});\n```\n\nThe expected output.\n```javascript\n[\n\t{\n\t\tname : \"title1\",\n\t\tinfo: \"description1\",\n\t\ttext: \"This is a blog.\",\n\t\tdate: 1383544800000,\n\t\tlink: \"http://goo.cm\",\n\t\tinfo: \"mike more info\",\n\t\tclearMe: \"\",\n\t\tfieldGroup: ['title1', { link : \"http://goo.cm\" }],\n\t\titerated: true\n\t}\n]\n```\n\n\n### Advanced Example\n\n```\nvar map = {\n\tlist: 'items',\n\titem: {\n\t\tid: 'id',\n\t\tsku: 'sku',\n\t\tzero: 'zero',\n\t\ttoReplace: 'sku',\n\t\terrorReplace: 'notFound',\n\t\tsimpleArray: ['id', 'sku','sku'],\n\t\tcomplexArray: [ {node: 'id'} , { otherNode:'sku' } , {toReplace:'sku'} ],\n\t\tsubObject: {\n\t\t\tnode1: 'id',\n\t\t\tnode2: 'sku',\n\t\t\tsubSubObject: {\n\t\t\t\tnode1: 'id',\n\t\t\t\tnode2: 'sku',\n\t\t\t}\n\t\t},\n\t\tremove: ['unwanted']\n\t},\n\tdefaults: {\n\t\t\"missingData\": true\n\t},\n\toperate: [\n\t\t{\n\t\t\trun: (val) =\u003e 'replacement',\n\t\t\ton: 'subObject.subSubObject.node1'\n\t\t},\n\t\t{\n\t\t\trun: (val) =\u003e 'replacement',\n\t\t\ton: 'errorReplace'\n\t\t},\n\t\t{\n\t\t\trun: (val) =\u003e 'replacement',\n\t\t\ton: 'toReplace'\n\t\t},\n\t\t\t{\n\t\t\trun: (val) =\u003e 'replacement',\n\t\t\ton: 'simpleArray.2'\n\t\t},\n\t\t{\n\t\t\trun: (val) =\u003e 'replacement',\n\t\t\ton: 'complexArray.2.toReplace'\n\t\t}\n\t]\n};\n\nvar object = {\n\titems:[\n\t\t{\n\t\t\tid: 'books',\n\t\t\tzero: 0,\n\t\t\tsku:'10234-12312',\n\t\t\tunwanted: true\n\t\t}\n\t]\n};\n\nvar result = JsonTransform(data, map).make();\n```\n\nThe expected output.\n```\n[\n\t{\n\t    \"id\": \"books\",\n\t    \"sku\": \"10234-12312\",\n\t    \"zero\": 0,\n\t    \"toReplace\": \"replacement\",\n\t    \"errorReplace\": \"replacement\",\n\t    \"simpleArray\": [\n\t        \"books\",\n\t        \"10234-12312\",\n\t        \"replacement\"\n\t    ],\n\t    \"complexArray\": [\n\t        {\n\t            \"node\": \"books\"\n\t        },\n\t        {\n\t            \"otherNode\": \"10234-12312\"\n\t        },\n\t        {\n\t            \"toReplace\": \"replacement\"\n\t        }\n\t    ],\n\t    \"subObject\": {\n\t        \"node1\": \"books\",\n\t        \"node2\": \"10234-12312\",\n\t        \"subSubObject\": {\n\t            \"node1\": \"replacement\",\n\t            \"node2\": \"10234-12312\"\n\t        }\n\t    },\n\t\t\"missingData\": true\n\t}\n]\n```\n\n### Multi-template Example\n\n```\nvar data = {\n    products: [{\n        id: 'books0',\n        zero: 0,\n        sku: '00234-12312',\n        subitems: [\n            { subid: \"0.0\", subsku: \"subskuvalue0.0\" },\n            { subid: \"0.1\", subsku: \"subskuvalue0.1\" }\n        ]\n    }, {\n        id: 'books1',\n        zero: 1,\n        sku: '10234-12312',\n        subitems: [\n            { subid: \"1.0\", subsku: \"subskuvalue1.0\" },\n            { subid: \"1.1\", subsku: \"subskuvalue1.1\" }\n        ]\n    }]\n};\n\nvar baseMap = {\n\t'list': 'products',\n\t'item' : {\n\t\t'myid': 'id',\n\t\t'mysku': 'sku',\n\t\t'mysubitems': 'subitems'\n\t},\n    operate: [\n        {\n            'run': function(ary) { \n            \treturn JsonTransform({list:ary}, nestedMap).make();\n            }, \n            'on': 'mysubitems'\n        }\n    ]\n};\n\nvar nestedMap = {\n\t'list': 'list',\n\t'item' : {\n\t\t'mysubid': 'subid',\n\t\t'mysubsku': 'subsku'\n\t}\n};\n\nvar result = JsonTransform(data, baseMap).make();\n```\n\nThe expected output.\n\n```\n[\n\t{\n\t    \"myid\": \"books0\",\n\t    \"mysku\": \"00234-12312\",\n\t    \"mysubitems\": [\n\t    \t{ \"mysubid\": \"0.0\", \"mysubsku\": \"subskuvalue0.0\" }, \n\t    \t{ \"mysubid\": \"0.1\", \"mysubsku\": \"subskuvalue0.1\"}\n\t    ]\n\t}, \n\t{\n\t    \"myid\": \"books1\",\n\t    \"mysku\": \"10234-12312\",\n\t    \"mysubitems\": [\n\t    \t{ \"mysubid\": \"1.0\", \"mysubsku\": \"subskuvalue1.0\" }, \n\t    \t{ \"mysubid\": \"1.1\", \"mysubsku\": \"subskuvalue1.1\" }\n\t    ]\n\t}\n]\n```\n\n### Context Example\n\nFirst we need some data.\n\n```javascript\n    var data = {\n        posts : [\n            {\n                title : \"title1\",\n                description: \"description1\"\n            }\n        ]\n    };\n```\n\nThe map defines how the output will be structured and which operations to run.\n\n```javascript\n    var map = {\n        list : 'posts',\n        item: {\n            name: \"title\",\n            info: \"description\"\n        },\n        operate: [\n            {\n                run: function(val, context) { return val + \" more info for\" + context.type},\n                on: \"info\"\n            }\n        ],\n        each: function(item, index, collection, context){\n            // make changes\n            item.type = context.type;\n            return item;\n        }\n    };\n```\n\nRun it\n```javascript\n    var jsonTransform = JsonTransform(data, map);\n    var context = { type: 'my-type' };\n    var result = jsonTransform.make(context);\n    console.log(result);\n```\n\nThe expected output.\n```javascript\n    [\n        {\n            name : \"title1\",\n            info: \"description1 more info for my-type\",\n            type: 'my-type'\n        }\n    ]\n```\n\n\nEnjoy!\n\n\n## Unit Test\nUnit test has been replaced from `jasmine-node` to `mocha` for better unit test.\n```bash\n$ npm test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faalfiann%2Fnative-json-transform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faalfiann%2Fnative-json-transform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faalfiann%2Fnative-json-transform/lists"}