{"id":15102751,"url":"https://github.com/orsiemilio/jsonshapeshifter","last_synced_at":"2026-01-19T04:32:22.265Z","repository":{"id":222557898,"uuid":"757722498","full_name":"orsiemilio/JsonShapeShifter","owner":"orsiemilio","description":"A flexible JSON transformation toolkit designed to standardize and restructure JSON data for seamless XML conversion, addressing the strict ordering requirements of SOAP-based services. Perfect for ensuring consistent data retrieval from MongoDB/Mongoose for reliable web service integration.","archived":false,"fork":false,"pushed_at":"2024-02-20T13:05:51.000Z","size":54,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T11:42:39.858Z","etag":null,"topics":["formatter","json","json-processing","json-processor","json-schema","json-sorting","json-transform","shape","shapeshift","shapeshifter","soap","sort","sorting"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orsiemilio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-14T20:57:48.000Z","updated_at":"2025-01-29T00:55:19.000Z","dependencies_parsed_at":"2024-09-20T08:00:37.357Z","dependency_job_id":"3f3a8fbe-11da-4131-b748-f3ce38bba8c5","html_url":"https://github.com/orsiemilio/JsonShapeShifter","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"68b9750fd31f91f63ec0691b6805cb15b60bc62e"},"previous_names":["orsiemilio/jsonshapeshifter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsiemilio%2FJsonShapeShifter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsiemilio%2FJsonShapeShifter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsiemilio%2FJsonShapeShifter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsiemilio%2FJsonShapeShifter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orsiemilio","download_url":"https://codeload.github.com/orsiemilio/JsonShapeShifter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332525,"owners_count":20921852,"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":["formatter","json","json-processing","json-processor","json-schema","json-sorting","json-transform","shape","shapeshift","shapeshifter","soap","sort","sorting"],"created_at":"2024-09-25T19:06:03.860Z","updated_at":"2026-01-19T04:32:22.251Z","avatar_url":"https://github.com/orsiemilio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# JsonShapeShifter\n\n[![codecov](https://codecov.io/gh/orsiemilio/JsonShapeShifter/graph/badge.svg?token=SMTK5VI1E2)](https://codecov.io/gh/orsiemilio/JsonShapeShifter)\n[![Test](https://github.com/orsiemilio/JsonShapeShifter/actions/workflows/test.yml/badge.svg)](https://github.com/orsiemilio/JsonShapeShifter/actions/workflows/test.yml)\n\nJsonShapeShifter is a handy tool made to change JSON objects into different shapes using specific rules and functions you set. It's super useful for a bunch of tasks, like fixing up data to send over the web, organizing information, or even getting data ready to be turned into XML for special web services, where keeping things in the right order is super important.\n\nA while back, I faced issues with the structure of JSON data from MongoDB. To solve this, especially since I had to work with SOAP-based services where XML demands precise ordering of values, I developed a solution similar to this.\n\n## Features\n\n- **Flexible JSON Transformation**: Transform JSON objects and arrays with ease using customizable templates.\n- **Custom Processing Functions**: Apply custom functions to process keys and leaf nodes, providing extensive control over the transformation.\n- **Path-Specific Processing**: Use path processors for targeted transformations, including support for wildcard processing in arrays.\n\n## Usage\n\n### Basic Transformation\n\n```javascript\nconst JsonShapeShifter = require('json-shape-shifter');\n\nconst shaper = new JsonShapeShifter();\nconst input = { name: \"John\", age: 30, favoriteHero: \"MacGiver\" };\nconst template = { favoriteHero: undefined, name: undefined }; // Doesn't includes 'age' and 'favoriteHero' goes first\n\nconst output = shaper.formatJsByTemplate(input, template);\nconsole.log(output); // Output: { favoriteHero: \"MacGiver\", name: \"John\" }\n```\n\n## Custom Key and Leaf Processing\n```javascript\nconst shaper = new JsonShapeShifter({\n  keysProcessor: (key) =\u003e key.toUpperCase(),\n  leafProcessor: (value) =\u003e typeof value === \"string\" ? value.toUpperCase() : value,\n});\n\nconst input = { name: \"John\" };\nconst output = shaper.formatJsByTemplate(input);\nconsole.log(output); // Output: { NAME: \"JOHN\" }\n```\n\n## Path-Specific Processing\n```javascript\nconst shaper = new JsonShapeShifter({\n  pathProcessors: {\n    \"details.age\": (value) =\u003e value \u003e 18 ? \"adult\" : \"minor\",\n  },\n});\n\nconst input = { details: { age: 20 } };\nconst template = { details: { age: undefined } };\n\nconst output = shaper.formatJsByTemplate(input, template);\nconsole.log(output); // Output: { details: { age: \"adult\" } }\n```\n\n## Array Processing with Wildcards\n```javascript\nconst config = {\n  pathProcessors: {\n    \"hobbies[*].name\": (value) =\u003e value.toUpperCase(),\n  },\n};\n\nconst shaper = new JsonShapeShifter(config);\n\nconst input = {\n  hobbies: [\n    { name: \"sing\" },\n    { name: \"dance\" },\n    { name: \"draw\" },\n  ],\n};\n\nconst output = shaper.formatJsByTemplate(input);\nconsole.log(output);\n// Output: { hobbies: [{ name: \"SING\" }, { name: \"DANCE\" }, { name: \"DRAW\" }] }\n```\n\n## TODO\n- Create a package for distribution.\n- Add Express support?? Evaluate the feasibility and benefits of integrating with Express for standardizing JSON responses and dynamically filtering fields.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forsiemilio%2Fjsonshapeshifter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forsiemilio%2Fjsonshapeshifter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forsiemilio%2Fjsonshapeshifter/lists"}