{"id":26643699,"url":"https://github.com/kosich/js-object-transformation","last_synced_at":"2026-06-28T02:32:36.753Z","repository":{"id":36166031,"uuid":"40470112","full_name":"kosich/js-object-transformation","owner":"kosich","description":"object transfrormation using jsonpath syntax","archived":false,"fork":false,"pushed_at":"2015-08-16T09:44:43.000Z","size":136,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T20:38:47.031Z","etag":null,"topics":[],"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/kosich.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}},"created_at":"2015-08-10T07:52:49.000Z","updated_at":"2015-08-12T19:24:59.000Z","dependencies_parsed_at":"2022-07-24T18:47:13.837Z","dependency_job_id":null,"html_url":"https://github.com/kosich/js-object-transformation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kosich/js-object-transformation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosich%2Fjs-object-transformation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosich%2Fjs-object-transformation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosich%2Fjs-object-transformation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosich%2Fjs-object-transformation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kosich","download_url":"https://codeload.github.com/kosich/js-object-transformation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosich%2Fjs-object-transformation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34875357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-03-24T20:34:41.914Z","updated_at":"2026-06-28T02:32:36.731Z","avatar_url":"https://github.com/kosich.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Intro\n\nA tool to transform one js object into another\n\n### Word of warning\n\nThis code is at version **0.0.0** so its interface might be changed in the future\n\nCode is written in **es6** *(a.k.a. js2015)* and needs [babel](https://babeljs.io/docs/usage/cli/) for transpiling and running unit tests\n\nIs not published to any package manager repo\n\nJSON path syntax is not fully supported (e.g. no relative paths, no array items by index etc)\n\n# Examples\n\n```js\nimport transform from '../src/main.js';\n```\n\n#### Simple\n```js\n// get value from 'a' property\ntransform({ a: '_a_' }, '$.a'); // \u003e '_a_'\n\n// get value from the sub property\ntransform({ a: { b: '_b_' }}, '$.a.b'); // \u003e '_b_'\n\n// get array and apply some modificator to it\ntransform({ c: [1, 5, 2, 3] }, ['$.c[*]', c=\u003eMath.max(...c) ]); // \u003e 5\n```\n\n#### Object\n```js\nlet src = {\n    a: { sub: 'bio' },\n    b: 'hazard',\n    c: [ 'c', 'e', 'l', 'l' ]\n};\n\nlet mod = {\n    // $ points to the source's root\n\n    // just copy value from 'b' to 'y'\n    y: '$.b',\n\n    // get 'a.sub' from src and put it to 'x' \n    x: '$.a.sub',\n\n    // get 'b' property and src itself\n    // and then apply modificator\n    // and put to z\n    z: [ '$.a', '$', (a,$)=\u003e`${a.sub.toUpperCase()} ${$.b}` ],\n\n    // again, simple copying of array\n    // but putting it to sub property\n    c: { cell: '$.c[*]' },\n\n    // apply some modificator to array from src\n    // and put it to 'r'\n    r: ['$.c[*]', c=\u003ec.join('')]\n};\n\n\nlet result = transform(src, mod);\n\nresult === {\n    y: 'hazard',\n    x: 'bio',\n    z: 'BIO hazard',\n    c: { cell: [ 'c', 'e', 'l', 'l'  ]  },\n    r: 'cell'\n};\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkosich%2Fjs-object-transformation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkosich%2Fjs-object-transformation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkosich%2Fjs-object-transformation/lists"}