{"id":13527886,"url":"https://github.com/bestiejs/json3","last_synced_at":"2025-09-27T08:30:44.316Z","repository":{"id":2442478,"uuid":"3412691","full_name":"bestiejs/json3","owner":"bestiejs","description":"A JSON polyfill. No longer maintained.","archived":true,"fork":false,"pushed_at":"2019-05-27T23:09:36.000Z","size":12076,"stargazers_count":1017,"open_issues_count":17,"forks_count":150,"subscribers_count":56,"default_branch":"master","last_synced_at":"2025-01-15T04:56:09.019Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://bestiejs.github.io/json3","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bestiejs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-11T01:18:46.000Z","updated_at":"2024-12-28T07:35:46.000Z","dependencies_parsed_at":"2022-08-06T12:15:25.626Z","dependency_job_id":null,"html_url":"https://github.com/bestiejs/json3","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestiejs%2Fjson3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestiejs%2Fjson3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestiejs%2Fjson3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestiejs%2Fjson3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bestiejs","download_url":"https://codeload.github.com/bestiejs/json3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234268866,"owners_count":18805646,"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-08-01T06:02:05.236Z","updated_at":"2025-09-27T08:30:38.913Z","avatar_url":"https://github.com/bestiejs.png","language":"JavaScript","readme":"# 🚨 Unmaintained 🚨\n\n\u003cp class=\"banner\"\u003eJSON 3 is **deprecated** and **no longer maintained**. Please don't use it in new projects, and migrate existing projects to use the native `JSON.parse` and `JSON.stringify` instead.\u003c/p\u003e\n\nThanks to everyone who contributed patches or found it useful! ❤️\n\n# JSON 3 #\n\n [![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\n**JSON 3** was a JSON polyfill for older JavaScript platforms.\n\n## About ##\n\n[JSON](http://json.org/) is a language-independent data interchange format based on a loose subset of the JavaScript grammar. Originally popularized by [Douglas Crockford](http://www.crockford.com/), the format was standardized in the [fifth edition](http://es5.github.io/) of the ECMAScript specification. The 5.1 edition, ratified in June 2011, incorporates several modifications to the grammar pertaining to the serialization of dates.\n\nJSON 3 exposes two functions: `stringify()` for [serializing](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/JSON/stringify) a JavaScript value to JSON, and `parse()` for [producing](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/JSON/parse) a JavaScript value from a JSON source string. The JSON 3 parser uses recursive descent instead of `eval` and regular expressions, which makes it slower on older platforms compared to [JSON 2](http://json.org/js). The functions behave exactly as described in the ECMAScript spec, **except** for the date serialization discrepancy noted below.\n\nThe project is [hosted on GitHub](http://git.io/json3), along with the [unit tests](http://bestiejs.github.io/json3/test/test_browser.html). It is part of the [BestieJS](https://github.com/bestiejs) family, a collection of best-in-class JavaScript libraries that promote cross-platform support, specification precedents, unit testing, and plenty of documentation.\n\n## Date Serialization\n\n**JSON 3 deviates from the specification in one important way**: it does not define `Date#toISOString()` or `Date#toJSON()`. This preserves CommonJS compatibility and avoids polluting native prototypes. Instead, date serialization is performed internally by the `stringify()` implementation: if a date object does not define a custom `toJSON()` method, it is serialized as a [simplified ISO 8601 date-time string](http://es5.github.com/#x15.9.1.15).\n\n**Several native `Date#toJSON()` implementations produce date time strings that do *not* conform to the grammar outlined in the spec**. In these environments, JSON 3 will override the native `stringify()` implementation. There is an [issue](https://github.com/bestiejs/json3/issues/73) on file to make these tests less strict.\n\nPortions of the date serialization code are adapted from the [`date-shim`](https://github.com/Yaffle/date-shim) project.\n\n# Usage #\n\n## Web Browsers\n\n    \u003cscript src=\"//cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      JSON.stringify({\"Hello\": 123});\n      // =\u003e '{\"Hello\":123}'\n      JSON.parse(\"[[1, 2, 3], 1, 2, 3, 4]\", function (key, value) {\n        if (typeof value == \"number\") {\n          value = value % 2 ? \"Odd\" : \"Even\";\n        }\n        return value;\n      });\n      // =\u003e [[\"Odd\", \"Even\", \"Odd\"], \"Odd\", \"Even\", \"Odd\", \"Even\"]\n    \u003c/script\u003e\n\n**When used in a web browser**, JSON 3 exposes an additional `JSON3` object containing the `noConflict()` and `runInContext()` functions, as well as aliases to the `stringify()` and `parse()` functions.\n\n### `noConflict` and `runInContext`\n\n* `JSON3.noConflict()` restores the original value of the global `JSON` object and returns a reference to the `JSON3` object.\n* `JSON3.runInContext([context, exports])` initializes JSON 3 using the given `context` object (e.g., `window`, `global`, etc.), or the global object if omitted. If an `exports` object is specified, the `stringify()`, `parse()`, and `runInContext()` functions will be attached to it instead of a new object.\n\n### Asynchronous Module Loaders\n\nJSON 3 is defined as an [anonymous module](https://github.com/amdjs/amdjs-api/wiki/AMD#define-function-) for compatibility with [RequireJS](http://requirejs.org/), [`curl.js`](https://github.com/cujojs/curl), and other asynchronous module loaders.\n\n    \u003cscript src=\"//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      require({\n        \"paths\": {\n          \"json3\": \"./path/to/json3\"\n        }\n      }, [\"json3\"], function (JSON) {\n        JSON.parse(\"[1, 2, 3]\");\n        // =\u003e [1, 2, 3]\n      });\n    \u003c/script\u003e\n\nTo avoid issues with third-party scripts, **JSON 3 is exported to the global scope even when used with a module loader**. If this behavior is undesired, `JSON3.noConflict()` can be used to restore the global `JSON` object to its original value.\n\n**Note:** If you intend to use JSON3 alongside another module, **please do not simply concatenate these modules together**, as that would cause multiple `define` calls in one script, resulting in errors in AMD loaders. The `r.js` build optimizer can be used instead if you need a single compressed file for production.\n\n## CommonJS Environments\n\n    var JSON3 = require(\"./path/to/json3\");\n    JSON3.parse(\"[1, 2, 3]\");\n    // =\u003e [1, 2, 3]\n\n## JavaScript Engines\n\n    load(\"path/to/json3.js\");\n    JSON.stringify({\"Hello\": 123, \"Good-bye\": 456}, [\"Hello\"], \"\\t\");\n    // =\u003e '{\\n\\t\"Hello\": 123\\n}'\n\n# Compatibility #\n\nJSON 3 has been **tested** with the following web browsers, CommonJS environments, and JavaScript engines.\n\n## Web Browsers\n\n- Windows [Internet Explorer](http://windows.microsoft.com/en-us/internet-explorer/download-ie), version 6.0 and higher\n- Google [Chrome](http://www.google.com/chrome), version 19.0 and higher\n- Mozilla [Firefox](https://www.mozilla.org/en-US/firefox/new/), version 2.0 and higher\n- Apple [Safari](http://www.apple.com/safari/), version 3.0 and higher\n- [Opera](http://www.opera.com/) 8.54 and higher\n- [SeaMonkey](http://www.seamonkey-project.org/) 1.0 and higher\n\n## CommonJS Environments\n\n- [Node](http://nodejs.org/) 0.6.21 and higher\n- [io.js](https://iojs.org/) 1.0.3 and higher\n- [RingoJS](http://ringojs.org/) 0.9 and higher\n- [Narwhal](https://github.com/280north/narwhal) 0.3.2\n\n## JavaScript Engines\n\n- Mozilla [Rhino](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino) 1.7R3 and higher\n- WebKit [JSC](https://trac.webkit.org/wiki/JSC)\n- Google [V8](http://code.google.com/p/v8/)\n\n## Known Incompatibilities\n\n* Attempting to serialize the `arguments` object may produce inconsistent results across environments due to specification version differences. As a workaround, please convert the `arguments` object to an array first: `JSON.stringify([].slice.call(arguments, 0))`.\n\n## Required Native Methods\n\nJSON 3 assumes that the following methods exist and function as described in the ECMAScript specification:\n\n- The `Number`, `String`, `Array`, `Object`, `Date`, `SyntaxError`, and `TypeError` constructors.\n- `String.fromCharCode`\n- `Object#toString`\n- `Object#hasOwnProperty`\n- `Function#call`\n- `Math.floor`\n- `Number#toString`\n- `Date#valueOf`\n- `String.prototype`: `indexOf`, `charCodeAt`, `charAt`, `slice`, `replace`.\n- `Array.prototype`: `push`, `pop`, `join`.\n","funding_links":[],"categories":["JavaScript","Web 前端","Misc","Objects","Misc [🔝](#readme)","大杂烩"],"sub_categories":["Other","其它"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestiejs%2Fjson3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbestiejs%2Fjson3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestiejs%2Fjson3/lists"}