Registry / testing / json-test-suite

json-test-suite

JSON →
library1.0.0jsnpmunverified

json-test-suite provides a programmatic interface to the `JSONTestSuite` data, specifically designed for testing JSON parsers. This package, currently at version 1.0.0, extracts the diverse set of JSON test cases into easily consumable JavaScript objects. It includes both valid and invalid JSON strings, along with examples designed to stress-test various aspects of JSON parsing, such as large numbers, specific character encodings, and edge cases. Its release cadence appears to be stable, with 1.0.0 being the initial significant release. Key differentiators include its direct consumption of the `nst/JSONTestSuite` data, making it a reliable source for parser validation without manual data management, and its provision of TypeScript types for improved developer experience. It primarily focuses on data delivery rather than providing a parsing implementation.

npm install json-test-suite
INSTALL
IMPORT
SIG · JSON-TEST-SUITE
J
json-test-suite
testingjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parsing
import { parsing } from 'json-test-suite'
const { parsing } = require('json-test-suite')
Primary named export for valid JSON parsing test cases. While technically possible with CommonJS `require` in some environments, the package is designed for ES module usage.
transform
import { transform } from 'json-test-suite'
const { transform } = require('json-test-suite')
Primary named export for JSON transformation test cases, often used to verify parser behavior on specific numeric or string representations.

Demonstrates how to import and access the `parsing` and `transform` test suites, and provides an example of using the 'parsing' data with `JSON.parse`.

import { parsing, transform } from 'json-test-suite'; // Access the array of JSON parsing test cases console.log('Parsing Test Cases Count:', parsing.length); console.log('First parsing test case example:', parsing[0]); // Access the array of JSON transformation test cases console.log('Transformation Test Cases Count:', transform.length); console.log('First transformation test case example:', transform[0]); // Example of using a test case with a standard JSON parser const firstValidCase = parsing.find(test => test.name.startsWith('y_')); // 'y_' indicates valid JSON if (firstValidCase) { try { const parsed = JSON.parse(firstValidCase.input); console.log(`Successfully parsed '${firstValidCase.name}':`, parsed); } catch (error) { console.error(`Failed to parse '${firstValidCase.name}':`, error.message); } }
Debug
Known issues
gotchaThis package provides raw JSON test data as strings and objects; it does not include or provide a JSON parser itself. Users must integrate their own JSON parsing mechanism (e.g., `JSON.parse` or a third-party library) to process the `input` strings provided by the test suite.
fix
Ensure you have a JSON parser available in your environment and explicitly use it to process the `input` property of the test cases (e.g., `JSON.parse(testCase.input)`).
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Attempting to use ES module `import` syntax in a CommonJS environment without proper configuration (e.g., `'type': 'module'` in `package.json` or a transpiler).
fix
Ensure your project's `package.json` includes `'type': 'module'` to enable ES modules, or use a bundler (like Webpack, Rollup, Parcel) that can transpile ES module syntax for CommonJS targets. Alternatively, if strictly in CommonJS and `import` is not an option, consider dynamic `import()` for specific scenarios.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
json-test-suite — npm install json-test-suite · libregistry