{"id":16355969,"url":"https://github.com/timobechtel/json2url","last_synced_at":"2025-03-23T01:31:23.240Z","repository":{"id":38175088,"uuid":"249390721","full_name":"TimoBechtel/json2url","owner":"TimoBechtel","description":"Encodes and decodes javascript objects into/from an url usable string","archived":false,"fork":false,"pushed_at":"2023-03-04T07:35:09.000Z","size":1438,"stargazers_count":2,"open_issues_count":15,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T16:14:45.813Z","etag":null,"topics":["javascript","json","parser","url"],"latest_commit_sha":null,"homepage":"https://timobechtel.github.io/json2url/","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/TimoBechtel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2020-03-23T09:44:37.000Z","updated_at":"2023-03-07T02:39:31.000Z","dependencies_parsed_at":"2024-10-28T15:21:06.887Z","dependency_job_id":"314235fb-0df8-44a6-bedd-fe40d556492e","html_url":"https://github.com/TimoBechtel/json2url","commit_stats":{"total_commits":34,"total_committers":4,"mean_commits":8.5,"dds":0.3529411764705882,"last_synced_commit":"1e5688a312a7064dc6ab33dca791aca1ce99d2b4"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimoBechtel%2Fjson2url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimoBechtel%2Fjson2url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimoBechtel%2Fjson2url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimoBechtel%2Fjson2url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimoBechtel","download_url":"https://codeload.github.com/TimoBechtel/json2url/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245043941,"owners_count":20551852,"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":["javascript","json","parser","url"],"created_at":"2024-10-11T01:42:17.193Z","updated_at":"2025-03-23T01:31:22.832Z","avatar_url":"https://github.com/TimoBechtel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json2url\n\nEncodes and decodes JavaScript objects into/from an URL usable string\n\n**✨[Demo](https://timobechtel.github.io/json2url/)**\n\n\n## Motivation\n\nThe goal was to create URLs as small as possible by using a template approach.\nIf don't care about the length of the url, you can just use something simpler like this:\n\n```js\nconst serialize = obj =\u003e encodeURIComponent(JSON.stringify(obj));\nconst deserialize = str =\u003e JSON.parse(decodeURIComponent(str));\n```\n\nOtherwise, read on.\n\n## Getting Started\n\n### Installing\n\n#### NPM:\n\n```\nnpm i json2url\n```\n\n#### CDN:\n\n```html\n\u003cscript src=\"https://unpkg.com/json2url/dist/index.umd.js\"\u003e\u003c/script\u003e\n```\n\n#### Locally:\n\nDownload \u003chttps://unpkg.com/json2url/dist/index.umd.js\u003e and link it in your html.\n\n### Using\n\n#### Example\n\n```html\n\u003cinput type=\"range\" id=\"a\" value=\"0\" /\u003e\n\u003cinput type=\"range\" id=\"b\" value=\"0\" /\u003e\n\u003cinput type=\"range\" id=\"c\" value=\"0\" /\u003e\n\u003cinput type=\"range\" id=\"d\" value=\"0\" /\u003e\n\n\u003cbutton onclick=\"serialize()\"\u003eSerialize\u003c/button\u003e\n\u003ctextarea id=\"out\" cols=\"30\" rows=\"10\"\u003e\u003c/textarea\u003e\n\n\u003cscript src=\"https://unpkg.com/json2url/dist/index.umd.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const template = {\n    a: 0,\n    b: 0,\n    c: 0,\n    d: 0,\n  };\n  const config = { ...template };\n\n  const inputIds = ['a', 'b', 'c', 'd'];\n\n  window.addEventListener('load', () =\u003e {\n    inputIds.forEach((id) =\u003e {\n      document.getElementById(id).addEventListener('change', (e) =\u003e {\n        config[id] = e.target.value;\n      });\n    });\n  });\n\n  function serialize() {\n    const serialized = json2Url.serialize(config);\n    document.getElementById('out').value = serialized;\n    console.log(json2Url.deserialize(serialized, template));\n  }\n\u003c/script\u003e\n```\n\n## Testing\n\n```\nnpm run test\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimobechtel%2Fjson2url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimobechtel%2Fjson2url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimobechtel%2Fjson2url/lists"}