{"id":13404,"library":"json-test-suite","title":"JSON Parsing Test Suite Data","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/fisker/json-test-suite","tags":["javascript","typescript"],"install":[{"cmd":"npm install json-test-suite","lang":"bash","label":"npm"},{"cmd":"yarn add json-test-suite","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-test-suite","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const { parsing } = require('json-test-suite')","symbol":"parsing","correct":"import { parsing } from 'json-test-suite'"},{"note":"Primary named export for JSON transformation test cases, often used to verify parser behavior on specific numeric or string representations.","wrong":"const { transform } = require('json-test-suite')","symbol":"transform","correct":"import { transform } from 'json-test-suite'"}],"quickstart":{"code":"import { parsing, transform } from 'json-test-suite';\n\n// Access the array of JSON parsing test cases\nconsole.log('Parsing Test Cases Count:', parsing.length);\nconsole.log('First parsing test case example:', parsing[0]);\n\n// Access the array of JSON transformation test cases\nconsole.log('Transformation Test Cases Count:', transform.length);\nconsole.log('First transformation test case example:', transform[0]);\n\n// Example of using a test case with a standard JSON parser\nconst firstValidCase = parsing.find(test => test.name.startsWith('y_')); // 'y_' indicates valid JSON\nif (firstValidCase) {\n  try {\n    const parsed = JSON.parse(firstValidCase.input);\n    console.log(`Successfully parsed '${firstValidCase.name}':`, parsed);\n  } catch (error) {\n    console.error(`Failed to parse '${firstValidCase.name}':`, error.message);\n  }\n}","lang":"typescript","description":"Demonstrates how to import and access the `parsing` and `transform` test suites, and provides an example of using the 'parsing' data with `JSON.parse`."},"warnings":[{"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)`).","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"Attempting to use ES module `import` syntax in a CommonJS environment without proper configuration (e.g., `'type': 'module'` in `package.json` or a transpiler).","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}