2betop / json-ast-comments

parser json string (with comments) into json, stringify json to string(with comments)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

json-ast-comments

parser json string (with comments) into json, stringify json to string(with comments)

usage

npm i json-ast-comments;
import { parse, stringify, parser } from "json-ast-comments";

const source = `
{
  // this is comments
  "a": 123
}
`;

const obj = parse(source);

console.log(obj);
console.log(stringify(obj));

const ast = parser.parse(source);
console.log(ast);

About

parser json string (with comments) into json, stringify json to string(with comments)

License:Apache License 2.0


Languages

Language:TypeScript 66.9%Language:Yacc 27.7%Language:JavaScript 5.4%