{"id":25790,"library":"jitson","title":"jitson","description":"Just-In-Time JSON.parse compiler that optimizes parsing by schema sampling. Version 1.0.0 is stable. It samples incoming JSON data and if a stable schema is detected, compiles a fast parser using turbo-json-parse. Differentiators: JIT compilation based on runtime schema analysis, supports Node.js buffers for faster parsing. Maintained by mafintosh. Release cadence is low; no recent updates.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/mafintosh/jitson","tags":["javascript"],"install":[{"cmd":"npm install jitson","lang":"bash","label":"npm"},{"cmd":"yarn add jitson","lang":"bash","label":"yarn"},{"cmd":"pnpm add jitson","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Uses turbo-json-parse to compile optimized parsers when schema is stable.","package":"turbo-json-parse","optional":false}],"imports":[{"note":"Package is ESM-only; use ESM import or dynamic import() in CommonJS.","wrong":"const jitson = require('jitson')","symbol":"default (jitson function)","correct":"import jitson from 'jitson'"},{"note":"jitson is a factory function, not a class. Do not use 'new'.","wrong":"const parse = new jitson()","symbol":"jitson constructor","correct":"const parse = jitson()"},{"note":"parse expects a JSON string or Buffer, not a parsed object.","wrong":"parse(JSON.parse(jsonString))","symbol":"parse function","correct":"const obj = parse(jsonString)"},{"note":"After parsing, check parse.schema to see if an optimized parser is being used (null if not).","wrong":"","symbol":"parse.schema","correct":"const schema = parse.schema"}],"quickstart":{"code":"import jitson from 'jitson';\n\nconst parse = jitson({ sampleInterval: 10 });\n\nfor (let i = 0; i < 10; i++) {\n  const obj = parse(JSON.stringify({ hello: 'world', number: Math.random() }));\n  console.log(obj);\n}\n\nconsole.log('Optimized schema:', parse.schema);","lang":"javascript","description":"Demonstrates JIT compilation: after several parses with a stable schema, parse.schema becomes non-null."},"warnings":[{"fix":"Call jitson() directly (const parse = jitson()).","message":"jitson is not a class; do not use 'new'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pass JSON.stringify output to parse, not JSON.parse output.","message":"The parse function expects a string or Buffer, not a parsed object.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Fall back to JSON.parse manually if jitson throws.","message":"The underlying turbo-json-parse may fail for very complex or nested schemas.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Create one jitson instance per API endpoint or data source.","message":"Schema detection works best when each endpoint uses a separate jitson instance.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"const parse = jitson(); // No 'new' keyword","cause":"Using 'new jitson()' instead of calling jitson() as a function.","error":"TypeError: jitson is not a constructor"},{"fix":"Call parse() at least once before checking parse.schema. After schema stabilization it will be an object.","cause":"Accessing parse.schema before any parsing has been done.","error":"TypeError: parse.schema is not an object"},{"fix":"Simplify the JSON data structure or fall back to JSON.parse.","cause":"The JSON schema is too complex for turbo-json-parse to compile.","error":"Error: Unable to compile parser - schema too complex"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}