A lightweight, zero-dependency JSON parser that produces an Abstract Syntax Tree (AST) with full location information. Version 2.1.0 supports Emoji, runs on Node >=4, and provides error messages with precise character offsets. Unlike JSON.parse, it returns a structured tree with node types like 'object', 'array', 'identifier', 'literal' and detailed 'loc' (location) data including line, column, offset, and source. Ideal for linters, formatters, code mods, and tools needing to analyze or manipulate JSON structure. Last released in 2019 with no recent updates, possibly in maintenance mode.
npm install json-to-astVerified import paths — ran on the pinned version, not inferred.
Parses a JSON string into an AST with location info (loc: true) and source name.
Use 'loc: true' instead of 'verbose: true'; update node type references to new names.
Access 'raw' instead of 'rawValue' on literal nodes.
Access 'loc' instead of 'position' for location data.
Consider alternatives like @humanwhocodes/momoa or moo/ace for active development.
Use named import for clarity: import { parse } from 'json-to-ast';Ensure 'source' is a string: parse(json, { source: 'file.json' })Use correct import: import parse from 'json-to-ast' or const parse = require('json-to-ast').default (for CJS with named export).Check the JSON input validity; the error message includes location details (line, column, offset).
No dependency data recorded yet.