package
ESTree-compatible JSON AST parser
npm install json-estree-astGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
A small wrapper around json-to-ast that translates its output to the ESTree Spec, which makes it usable for example as a jscodeshift parser.
npm install json-estree-astconst { parse } = require('json-estree-ast');
const options = {
loc: true, // include source location information. Default `true`
source: 'data.json' // include source information. Default `null`
};
parse('{"a": 1}', options);Output
{
type: 'Program',
body: [
{
type: 'ObjectExpression',
properties: [
{
type: 'Property',
key: {
type: 'Identifier',
name: 'a',
raw: '"a"',
loc: {
start: { line: 1, column: 1 },
end: { line: 1, column: 4 },
source: 'data.json'
}
},
kind: 'init',
value: {
type: 'Literal'
{
type: 'ObjectExpression',
properties: Property[],
loc?: SourceLocation
}{
type: 'Property',
key: Identifier,
kind: 'init',
value: ObjectExpression | ArrayExpression | Literal,
loc?: SourceLocation
}{
type: 'Identifier',
name: string,
raw: string,
loc?: SourceLocation
}{
type: 'ArrayExpression',
children: (ObjectExpression | ArrayExpression | Literal)[],
loc?: SourceLocation
}{
type: 'Literal',
value: string | number | boolean | null,
raw: string,
loc?: SourceLocation
}{
source?: string,
start: SourcePosition,
end: SourcePosition
}{
line: number,
column: number
}MIT
Estimated unpacked size across 4 packages.
378.5 kB
Includes dependencies.