{"id":15013513,"url":"https://github.com/luzlab/ejson-extras","last_synced_at":"2026-03-09T02:33:06.941Z","repository":{"id":57221164,"uuid":"112574603","full_name":"luzlab/ejson-extras","owner":"luzlab","description":"Extends EJSON with additional types","archived":false,"fork":false,"pushed_at":"2018-01-18T06:53:21.000Z","size":40,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-03T22:22:01.135Z","etag":null,"topics":["ejson","meteorjs"],"latest_commit_sha":null,"homepage":null,"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/luzlab.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":"2017-11-30T06:37:26.000Z","updated_at":"2018-01-24T19:40:12.000Z","dependencies_parsed_at":"2022-08-29T01:50:45.078Z","dependency_job_id":null,"html_url":"https://github.com/luzlab/ejson-extras","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/luzlab/ejson-extras","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luzlab%2Fejson-extras","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luzlab%2Fejson-extras/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luzlab%2Fejson-extras/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luzlab%2Fejson-extras/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luzlab","download_url":"https://codeload.github.com/luzlab/ejson-extras/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luzlab%2Fejson-extras/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30280877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:23:26.802Z","status":"ssl_error","status_checked_at":"2026-03-09T02:22:46.175Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ejson","meteorjs"],"created_at":"2024-09-24T19:44:22.616Z","updated_at":"2026-03-09T02:33:06.923Z","avatar_url":"https://github.com/luzlab.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Description\n\n`ejson` extends JSON to support more types, including user-defined types.\n`ejson-extras` adds support for additional types not included in `ejson`, such\nas the native `Map`. `ejson-extras` also enables importing EJSON-encoded JSON\nfiles.\n\n# Usage\n\n```javascript\nconst EJSON = require('ejson');\nrequire('ejson-extras').apply();\n\nconst map1 = new Map().set('foo', 'bar').set('hello', 'world');\nEJSON.stringify(map1); // '{\"$type\":\"Map\",\"$value\":\"[[\\\\\"foo\\\\\",\\\\\"bar\\\\\"],[\\\\\"hello\\\\\",\\\\\"world\\\\\"]]\"}'\nJSON.stringify(map1); // '{}'\n\nconst string = '{\"$type\":\"Map\",\"$value\":\"[[\\\\\"hello\\\\\",\\\\\"world\\\\\"]]\"}';\nEJSON.parse(string); // Map { 'hello' =\u003e 'world' }\n\nconst map2 = new Map().set('hello', 'world').set('foo', 'bar');\nEJSON.equals(map1, map2); // true\n```\n\n```javascript\n// test.json\n{ \"$type\": \"Map\", \"$value\": \"[[\\\"hello\\\",\\\"world\\\"]]\" }\n\n// in your javascript file\nrequire('ejson-extras').apply();\nlet data = require('./test.json') // Map { 'hello' =\u003e 'world' }\n```\n\n# Supported Types\n\nCurrently, `ejson-extras` adds support for the following types:\n\n* Maps\n* [Qtys](https://github.com/gentooboontoo/js-quantities)\n\nPlease submit an issue if you'd like to see an addtional type.\n\n# Creating a custom type\n\nAdding an additional type is as easy as adding a file to the /types directory.\nHere is a sample type file for supporting the native `Map` object:\n\n```javascript\nmodule.exports = {\n    prototype: Map.prototype,\n    shims: {\n        typeName() {\n            return 'Map';\n        },\n        toJSONValue() {\n            return JSON.stringify([...this]);\n        },\n        clone() {\n            return new Map(this);\n        },\n        equals(other) {\n            if (this.size !== other.size) return false;\n            Array.from(other.entries()).keys(key =\u003e {\n                return this.get(key) == other.get(key);\n            });\n        },\n    },\n    factory(json) {\n        return new Map(JSON.parse(jsonStr));\n    },\n    typeName: 'Map',\n};\n```\n\n# Peer Dependancies\n\nMany custom types will require a peer dependancy. An example of this is\n`jsQuantities.js`, in this case we use `try-require` to import the peer library.\nIf the peer library isn't found, ejson-extras will skip adding support for that\nparticular type.\n\n# Changes\n\n1.0.15 - Fixed Map EJSON stringify/parsing bug.\n\n1.0.11 - Fixed patching of 'require' inside Meteor.\n\n1.0.10 - Fixed ejson detection and import inside Meteor.\n\n1.0.9 - Reverted to standard try/catch syntax.\n\n1.0.8 - Handles multiple calls to apply().\n\n1.0.7 - Added Meteor autodetection for patching of bundled EJSON.\n\n1.0.6 - Removed dependancy on `fs` to enable browser usage of `ejson-extras`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluzlab%2Fejson-extras","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluzlab%2Fejson-extras","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluzlab%2Fejson-extras/lists"}