{"id":15047007,"url":"https://github.com/awwright/jsonschemaparse","last_synced_at":"2025-09-09T04:33:39.092Z","repository":{"id":44754150,"uuid":"71491241","full_name":"awwright/jsonschemaparse","owner":"awwright","description":"Streaming parser for JSON with automatic validation and customizable parsing","archived":false,"fork":false,"pushed_at":"2022-01-26T18:15:51.000Z","size":579,"stargazers_count":8,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-28T03:41:03.358Z","etag":null,"topics":["json","json-schema"],"latest_commit_sha":null,"homepage":"https://awwright.github.io/jsonschemaparse/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awwright.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":"2016-10-20T18:16:21.000Z","updated_at":"2025-07-18T01:53:17.000Z","dependencies_parsed_at":"2022-09-02T06:44:25.817Z","dependency_job_id":null,"html_url":"https://github.com/awwright/jsonschemaparse","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/awwright/jsonschemaparse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awwright%2Fjsonschemaparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awwright%2Fjsonschemaparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awwright%2Fjsonschemaparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awwright%2Fjsonschemaparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awwright","download_url":"https://codeload.github.com/awwright/jsonschemaparse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awwright%2Fjsonschemaparse/sbom","scorecard":{"id":219716,"data":{"date":"2025-08-11","repo":{"name":"github.com/awwright/jsonschemaparse","commit":"9c00eefe484af70e3c73eac72c4ae43e94f88148"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: UNLICENSE:0","Info: FSF or OSI recognized license: The Unlicense: UNLICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T02:14:31.085Z","repository_id":44754150,"created_at":"2025-08-17T02:14:31.094Z","updated_at":"2025-08-17T02:14:31.094Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273367406,"owners_count":25092863,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"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":["json","json-schema"],"created_at":"2024-09-24T20:53:52.147Z","updated_at":"2025-09-09T04:33:39.022Z","avatar_url":"https://github.com/awwright.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":" # JSONSchemaParse\n \n Parse a JSON Document into an object structure, validating it against a JSON Schema\n\nFeatures:\n\n* Stream parse a JSON document\n* Provide useful feedback about JSON parse errors\n\t- Line numbers\n\t- Repeated keys\n\t- Syntax errors\n* Validates the JSON document against a JSON Schema\n\t- Provides line/character information of error\n* Parse JSON instances into an instance of an arbitrary object - parse dates directly into Date, integers into arbitrary precision object, objects into Immutable Map, etc.\n\t- Allow JSON values to be filtered through a filter after parsing, so strings can be cast to Dates, objects to Immutable objects, etc.\n   - Filter based on schema URI, type, format, and non-trivial cases like too-big numbers, and whatever else is appropriate\n\n## API\n\n### parse(text)\n\nParses _text_ and turns it into a native value.\n\nFor reading a Uint8Array/Buffer, specify `charset` in the options (see the `parse(text, options)` form below).\n\n\n### parse(text, reviver)\n\nParses _text_ and turns it into a native value. The _reviver_ argument is applied to each value, compatible with ECMAScript `JSON.parse`.\n\nEquivalent to ECMAScript `JSON.parse(text, reviver)`.\n\n\n### parse(text, schema)\n\nParses _text_ while validating it against the Schema instance in the _schema_ argument. Parsing will terminate at the first validation error.\n\n```javascript\ntry {\n\tconst schema = new lib.Schema({ type: 'string' });\n\tconst value = lib.parse(jsonText, schema);\n}catch(e){\n\t// handle SchemaError or ValidationError\n}\n```\n\n\n### parse(text, options)\n\nParses _text_, and accepts an object _options_ as found in StreamParser, except for the \"parse\" options, which are called with the following values: `parseValue:true, parseAnnotations:false, parseInfo:false`.\n\n```javascript\ntry {\n\tconst value = lib.parse(jsonText, {\n\t\tschema: { type: 'string' },\n\t\tcharset: 'UTF-8',\n\t});\n}catch(e){\n\t// handle SchemaError or ValidationError\n}\n```\n\n\n### parseInfo(text, options)\n\nParses _text_ and returns an Instance instance. Use it when you need to know additional information about the JSON document, including JSON Schema annotations on each value, or the line/character position information of each value.\n\n`options` is an object with any of the following properties:\n\n* schema: a Schema instance, or an object representing a parsed schema document\n* reviver: An ECMAScript `JSON.parse` compatible reviving function.\n* charset: The character set, if `text` is a Uint8Array/Buffer. `ASCII` and `UTF-8` values permitted.\n* annotations: true/false to collect or ignore annotations. Default true.\n\n\nThe returned object will have the following properties:\n\n* type: object/array/string/number/boolean/null, depending on the type\n* native: the JSON.parse equivalent value\n* annotations: A list of all the JSON Schema annotations collected for this instance\n* links: A list of all the links collected through JSON Hyper-schema. Unlike \"annotations\", each rel= in a single link produces a new item in this list.\n* properties: if instance is an object, contains a list of PropertyInstance items.\n* keys: if instance is an object, contains a map of key names to PropertyInstance items.\n* key: if instance is a PropertyInstance, this contains a StringInstance holding the key of the property.\n* items: if instance is an array, contains a list of Instance items.\n* map: a Map of all the child objects/arrays in the instance, mapped to their corresponding Instance\n\n\n### new StreamParser(options)\n\nStreamParser is a writable stream that accepts a byte stream or string stream, and outputs events.\n\nIt outputs an \"end\" event when the document has been fully parsed.\n\noptions is an object with any of the following properties:\n\n* `schema`: A schema instance or plain object, to be validated against the incoming document.\n* `throw`: Treat a validation error as a syntax error; stops consumption of the stream and emits the first ValidationError encountered.\n* `charset`: The character set used to decode a Buffer/Uint8Array. Valid values: `ASCII`, `UTF-8`\n* `reviver`: A function that consumes and maps values immediately after validation (same interface as ECMAScript).\n* `parseValue`: if `true`, return value will include a `value` property with the JSON.parse equivalent parsed value. Default `false`.\n* `parseAnnotations`: If `true`, return value will include annotations/links properties, with JSON Schema annotations (e.g. the \"title\", \"description\" keywords.)\n* `parseInfo`: If `true`, return value will include properties/keys/map properties with StreamParser output from child instances.\n* `maxKeyLength`: Enforces a limit on object keys, in UTF-16 characters, for memory purposes\n* `maxStringLength`: Enforces a limit on strings (except keys), in UTF-16 characters, for memory purposes\n* `maxNumberLength`: Enforces a limit on the lexical representation of numbers, in characters, for memory purposes when \"bigNumber\" is enabled.\n* `maxItems`: Enforces a limit on number of items in each array, for memory purposes\n* `maxProperties`: Enforces a limit on number of properties in each object, for memory purposes\n* `maxUniqueItems`: Enforces a limit on size of all arrays tested by `uniqueItems` (since this is an O(n²) operation)\n* `interoperable`: Raise an error if the document is outside the I-JSON (RFC 7493) subset of JSON.\n* `bigNumber`: Determines behavior for numbers too large to represent in an ECMAScript number without loss of precision. See \"bigNumber\" section below for possible values.\n* `niceNumber`: Determines behavior for all other numbers (numbers accurately represented in an ECMAScript number).\n* `syntaxLineComment`: Treats `//` as whitespace until the end of the line\n* `syntaxHashComment`: Treats `#` as whitespace until the end of the line\n* `syntaxBlockComment`: Treats `/*` as whitespace until a `*/` sequence (no nested comments)\n* `syntaxNestedComment`: Treats `/*` as whitespace until a `*/` sequence (allows nesting, overrides syntaxBlockComment)\n* `syntaxUnquotedKeys`: Permits a bare, unqouted ECMAScript 5.1 IdentifierName as a property key\n* `syntaxTrailingComma`: Allows arrays and objects to end with a trailing comma (by configuring the parser so a comma doesn't imply another property/item)\n* `syntaxSingleQuote`: Permits single quotes for strings, including property keys\n* `syntaxEscapeLF`: A backslash linefeed sequence (i.e. a backslash as the last character on a line) will ignore the newline. (The backslash and LF character will both be discarded entirely.) This allows a ␊ character to be broken across multiple lines as the four-character string `\"\\n\\␊\"` (instead of the two character-string `\"\\n\"` all on a single line).\n* `syntaxUTF32`: Permits `\\Uxxxxxxxx` or `\\u{x...}` sequences (where `x` is a hex digit) for representing Unicode code points outside the BMP (Basic Multilingual Plane), that would normally only be escaped via a UTF-16 surrogate pair.\n* `syntaxHexadecimal`: Permits numbers starting with `0x` to be interpreted as hexadeciamal. Only integers can be expressed with this form.\n* `syntaxBareDecimal`: Permits numbers to start or end with a decimal (otherwise, a `0` would have to come before or after it).\n* `syntaxInf`: Permits `Infinity` and `-Infinity`. This is not compatible with JSON Schema, use with caution.\n* `syntaxNaN`: Permits `NaN` as a number value. This is not compatible with JSON Schema, use with caution.\n* `syntaxPlus`: Permits a leading + before a number.\n\nValues for \"bigNumber\" (all these options are performed after JSON Schema validation):\n\n* `default`: Use nearest floating point representation, same behavior as JSON.parse\n* `error`: Treat as a validation error\n* function: Pass a function `function(json, validator)` that returns the value to use.\n* `json`: Use the raw JSON in a string. This may be in exponential notation, depending on how it was present in the original document.\n* `string`: Cast to a decimal number. There will be an optional minus sign, one or more digits, a decimal point, and one or more digits. The `maxNumberLength` will be enforced on this new string, if present.\n* `intstr`: Encode as a string, but only guarantees the accuracy of the integer part. This is best used with the `type: \"integer\"` keyword.\n* `fraction`: will return an array with two BitInt numbers: the numerator, and denominator. The denominator will always be a non-negative exponent of 10, with one zero for each number past the decimal point.\n* `properfraction`: will return an array with three BitInt numbers: the whole part, the fractional part numerator, and the fractional part denominator. The denominator will always be a non-negative exponent of 10, with one zero for each number past the decimal point.\n\n```javascript\nvar parser = new StreamParser(new Schema('http://localhost/schema.json', {type: 'array'}), {parseValue:true});\n\nfs.createReadStream('file.json')\n\t.pipe(parser)\n\t.on('finish', function(err, res){\n\t\tconsole.log(parser.errors);\n\t\tconsole.log(parser.value);\n\t});\n```\n\n### StreamParser#done\n\nA Promise that resolves to the StreamParser when it parses and validates a document.\n\n\n### StreamParser#errors\n\nAn Array of ValidationError instances representing accumulated validation errors.\nParsing will end when an error is detected, not all errors in the document may be listed.\n\n\n### StreamParser#value\n\nIf `parseValue: true` was passed in `options`, the parsed value will be available here.\n\n\n### StreamParser#on('startObject', function() )\nEmitted when an object is opened (when `{` is observed).\n\n\n### StreamParser#on('endObject', function() )\nEmitted when an object is closed (when `}` is observed).\n\n\n### StreamParser#on('startArray', function() )\nEmitted when an array is opened (when `[` is observed).\n\n\n### StreamParser#on('endArray', function() )\nEmitted when an array is closed (when `]` is observed).\n\n\n### StreamParser#on('key', function(name) )\nEmitted inside an object when a key is fully parsed.\n\n\n### StreamParser#on('string', function(value) )\nEmitted when a string value is parsed.\n\n\n### StreamParser#on('boolean', function(value) )\nEmitted when a boolean value is parsed.\n\n\n### StreamParser#on('null', function(value) )\nEmitted when a null is parsed.\n\n\n### StreamParser#on('end', function() )\nEmitted when the incoming stream been fully consumed, parsed, and a final result is available.\n\n\n### new Schema(baseURI, schemaObject)\n\n* baseURI: The URI the schema was downloaded at, if any.\n* schemaObject: A parsed JSON schema. Must be an object, JSON Schema documents can simply be run through `JSON.parse` to generate a compatible object.\n\n```javascript\nvar schema = new Schema('http://localhost/schema.json', { type: 'array' });\nvar parser = schema.createParser({parseValue:true});\n\nfs.createReadStream('file.json')\n\t.pipe(parser)\n\t.on('finish', function(err, res){\n\t\tconsole.log(parser.errors);\n\t\tconsole.log(parser.value);\n\t});\n```\n\n### class: SchemaRegistry\n\nUse SchemaRegistry if one schema references another.\n\n\n### SchemaRegistry#import(uri, schema)\n\nImport a schema so that it may be referenced by its given URI by other schemas.\n\n```javascript\nvar registry = new SchemaRegistry();\nvar baseSchema = registry.import('http://localhost/schema.json', { type: 'array', items:{$ref:'http://localhost/item.json'} });\nvar stringSchema = registry.import('http://localhost/item.json', { type: 'string' });\n// Alternatively:\n// var schema = new Schema('http://localhost/schema.json', { type: 'array' }, registry);\nvar parser = baseSchema.createParser({parseValue:true});\n\nfs.createReadStream('file.json')\n\t.pipe(parser)\n\t.on('finish', function(err, res){\n\t\tconsole.log(parser.errors);\n\t\tconsole.log(parser.value);\n\t});\n```\n\n### ValidationError\n\nStores information about a failed validation of a keyword against an instance. Contains the following properties:\n\n* message: A human-readable, english message.\n* path: array of keys or array indexes leading to the instance.\n* layer: the current parse state of the current item in the stack\n* position: An object with line/column properties. Zero-indexed, and may vary depending on character set.\n* to: An object with line/column properties, indicating the position where the error ends.\n* schema: the Schema object that generated the error\n* schemaId: the URI address of the schema that generated the error\n* keyword: The keyword in the schema that generated the error\n* expected: The value of the keyword\n* actual: the value of the instance that failed validation\n\n\n### Interface: Validator\nA Validator is the paradigm used to validate information from the JSON parser as it is streaming. It validates a single instance against a single schema by reading SAX events from the parser, as well as listening to results from subordinate validators (Validator instances for child instances and subschemas), and comparing them to the range of events permitted by the schema.\n\nIt is an ECMAScript object that consumes information about a single layer in the parser stack as it tokenizes input.\nA validator only evaluates over a single layer in the stack (like an object or a string), it is not notified of events that happen in children or grandchildren layers.\nInstead, when a child is encountered (like an array item), a function is called requesting a list of validators that can process that sub-instance.\nWhen the child finishes parsing, the validator can then examine the return value and act on it.\n\nA new validator does not yet know the type of incoming value, and may not know until e.g. all whitespace is consumed. You must wait for a start{type} call.\n\n### new Validator(options, errors)\nCalled to create a validator, whenever a new layer in the parsing stack is entered.\n\nOptionally pass an outside array that errors will be pushed to.\nNormally, this will be the instance of StreamParser#errors, so that errors from all validators get gathered together at the parser.\nOtherwise, a local array will be created.\n\nThe parser will call the following methods, depending on the tokens it encounters during parsing:\n\n* Validator#startObject(layer)\n* Validator#endObject(layer)\n* Validator#validateProperty(k)\n* Validator#startKey(layer)\n* Validator#endKey(layer, name)\n* Validator#startArray(layer)\n* Validator#endArray(layer)\n* Validator#validateItem(i)\n* Validator#startNumber(layer)\n* Validator#endNumber(layer, value)\n* Validator#startString(layer)\n* Validator#endString(layer, value)\n* Validator#startBoolean(layer)\n* Validator#endBoolean(layer, value)\n* Validator#startNull(layer)\n* Validator#endNull(layer, value)\n\n\n## Table of Files\n\n* index.js: Entry point for Node.js\n* lib/parse.js: JSON parser\n* lib/schema.js: JSON validation logic \u0026 JSON Schema implementation\n* package.json: npm metadata\n* UNLICENSE: Public Domain dedication\n* test/schema-suite: link to the official JSON Schema test suite\n* test/syntax-suite: link to a JSON parser test suite\n* test/bin/perf.js: Performance test the parser\n* test/bin/perf-native.js: Compare performance to the ECMAScript built-in parser\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawwright%2Fjsonschemaparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawwright%2Fjsonschemaparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawwright%2Fjsonschemaparse/lists"}