{"id":22177867,"url":"https://github.com/aqzi/jsonmapping","last_synced_at":"2025-03-24T18:26:11.148Z","repository":{"id":57098483,"uuid":"391184967","full_name":"aqzi/JsonMapping","owner":"aqzi","description":"Convert json to and from (nested) maps and sets","archived":false,"fork":false,"pushed_at":"2021-08-03T08:23:19.000Z","size":117,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T20:08:18.891Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/aqzi.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":"2021-07-30T20:49:24.000Z","updated_at":"2021-08-03T08:23:22.000Z","dependencies_parsed_at":"2022-08-20T18:10:16.480Z","dependency_job_id":null,"html_url":"https://github.com/aqzi/JsonMapping","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aqzi%2FJsonMapping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aqzi%2FJsonMapping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aqzi%2FJsonMapping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aqzi%2FJsonMapping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aqzi","download_url":"https://codeload.github.com/aqzi/JsonMapping/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245326825,"owners_count":20597095,"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":[],"created_at":"2024-12-02T08:33:01.646Z","updated_at":"2025-03-24T18:26:11.127Z","avatar_url":"https://github.com/aqzi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JsonMapping\nConvert json to and from (nested) maps and sets.\n\n## Installation\n```\nnpm i @aqzi/jsonmapping\n```\n\n## Usage\n\n### Map/Set --\u003e Json\nThe mapper function adds an identifier to the map and set objects.\nWhen the parameter noIdentifier is true (default is false), it will convert the map to an object and the set will be a list.\n(Json.stringify would transform a map to an empty object.)\n\nMap --\u003e json:\n```typescript\nobj2Json({test: new Map(['😀', 1], ['👻', 2])})\n@return: {\"test\":{\"😀\":1,\"👻\":2,\"_map_\":true}}\n\n//with noIdentifier = true:\nobj2Json({test: new Map(['😀', 1], ['👻', 2])}, true)\n@return: {\"test\":{\"😀\":1,\"👻\":2}}\n```\n\nSet --\u003e json:\n```typescript\nobj2Json({test: new Set([1,2,3])})\n@return: {\"test\":{\"_set_\":[1,2,3]}}\n```\n\n### Json --\u003e Map/Set\nThe package provides two ways to reconstruct maps and sets correctly.\n1) identifiers: If the json contains identifiers it will automaticly perform the transformation.\n2) keysToConvert: You can specify some keys belonging to objects that should be converted.\n    if the same key is specified as value for Map and Set, than the corresponding object will be transformed\n    to a map. If the json contains multiple objects with the same key than all those objects will be converted\n    if that key was specified. Following code gives an example.\n\n```typescript\njson2Obj(dataAsJson, {Map: ['🐔', '🐷'], Set: ['😺']})\n```\n\nObject with keys 🐔 or 🐷 will be transformed to a map and an object with key 😺 will become a set.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faqzi%2Fjsonmapping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faqzi%2Fjsonmapping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faqzi%2Fjsonmapping/lists"}