{"id":19421491,"url":"https://github.com/tradologics/schemorfer","last_synced_at":"2025-08-29T21:39:31.837Z","repository":{"id":57167456,"uuid":"265282056","full_name":"tradologics/schemorfer","owner":"tradologics","description":"Schemorfer - The JSON object transformer","archived":false,"fork":false,"pushed_at":"2022-07-06T09:28:28.000Z","size":228,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-27T07:03:32.558Z","etag":null,"topics":["json","json-converter","json-schema","nodejs","npm"],"latest_commit_sha":null,"homepage":"https://npmjs.com/@tradologics/schemorfer","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tradologics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-19T15:11:30.000Z","updated_at":"2024-06-27T22:52:21.000Z","dependencies_parsed_at":"2022-09-18T16:02:23.532Z","dependency_job_id":null,"html_url":"https://github.com/tradologics/schemorfer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tradologics/schemorfer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradologics%2Fschemorfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradologics%2Fschemorfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradologics%2Fschemorfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradologics%2Fschemorfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tradologics","download_url":"https://codeload.github.com/tradologics/schemorfer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradologics%2Fschemorfer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264221462,"owners_count":23575014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-converter","json-schema","nodejs","npm"],"created_at":"2024-11-10T13:28:28.392Z","updated_at":"2025-08-29T21:39:31.820Z","avatar_url":"https://github.com/tradologics.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/tradologics/schemorfer/blob/main/assets/logo.png?raw=true\" height=\"72\"\u003e\n\n# The JSON Object Transformer\n\n\u003ca href=\"https://tradologics.com/opensource\"\u003e\u003cimg alt=\"npm Version\" src=\"https://img.shields.io/badge/By-Tradologics-7269a6\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/@tradologics/schemorfer\"\u003e\u003cimg alt=\"npm Version\" src=\"https://badge.fury.io/js/%40tradologics%2Fschemorfer.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.codefactor.io/repository/github/tradologics/schemorfer\"\u003e\u003cimg alt=\"Code Factor\" src=\"https://www.codefactor.io/repository/github/tradologics/schemorfer/badge\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/tradologics/schemorfer\"\u003e\u003cimg alt=\"Star this repo\" src=\"https://img.shields.io/github/stars/tradologics/schemorfer.svg?style=social\u0026label=Star\u0026maxAge=60\"\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/aroussi\"\u003e\u003cimg alt=\"Follow me on\" src=\"https://img.shields.io/twitter/follow/tradologics.svg?style=social\u0026label=Follow\u0026maxAge=60\"\u003e\u003c/a\u003e\n\n\n**Schemorfer** is a JSON Schema transformation library.\n\nIt converts the source `JSON` structure to a different one, based on a supplied **map** `JSON` file, which contains instructions on how to convert each element.\n\nSchemorfer also has the option to **validates** the schema against a valid e [JSON Schema](https://json-schema.org/understanding-json-schema/index.html) file. It uses [Ajv](https://github.com/ajv-validator/ajv) under the hood to validate, assign defaults to optional/empty properties, and remove empty properties from the source `JSON` data.\n\n**Schemorfer** was developed by [Tradologics](https://tradologics.com) to convert various JSON payloads from various API providers into a standardized, pre-defined format.\n\n## Install\n\n```\n$ npm install @tradologics/schemorfer\n```\n\n# Usage\n\n```javascript\nconst schemorfer = require('@tradologics/schemorfer');\n\n// option 1\nconst data = require('./post-payload.json');\nconst mapper = require('./post-mapper.json');\nconst newData = schemorfer.transform(data, mapper);\n\n// option 2\n// const newData = schemorfer.transform(\n//     './post-payload.json', './post-mapper.json');\n\nconsole.log(newData);\n```\n\n\n### Keywords\n\n```\n- $from = source key\n- $default = default value (if empty, undefined, or null)\n- $rename = array-based rename\n- $if\n    - $prop = the property to check against\n    - $is (for true/false)\n    - $typeof\n    - $condition, either\n        - $type = simple/const (default = simple)\n        - $const = eval statement\n- $then (required for if), either\n    - $from = source key\n    - $value = hard coded value\n- $else, either\n    - $from = source key\n    - $value = hard coded value\n- :: = nested source\n- $apply - optional function to manipulate the value (`value` is passed as parameter)\n```\n\n`$apply` example:\n```\n{\n  ...\n  \"$apply\": \"return value.toUpperCase()\"\n  ...\n}\n```\n\\* More docs coming soon 🙂\n\n---\n\n## JSON Schema Validation\n\n```javascript\nconst schemorfer = require('schemorfer');\n\n// option 1\nconst payload = require('./post-payload.json');\nconst schema = require('./post-schema.json');\nconst valid = schemorfer.validate(payload, schema);\n\n// option 2\n// const valid = schemorfer.validate(\n//     './post-payload.json', './post-schema.json');\n\nif (!valid) {\n    console.error(schemorfer.errors());\n}\n\n// payload now has all the optional fields populated with the defaults\nconsole.log(valid);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftradologics%2Fschemorfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftradologics%2Fschemorfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftradologics%2Fschemorfer/lists"}