Skip to main content

Built and signed on GitHub Actions

A parser that allows editing while _maintaining the structure_ of json.

This package works with Node.js, Deno, BunIt is unknown whether this package works with Cloudflare Workers, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
10 months ago (0.0.4)

perfect-json-parser

JSR

A parser that allows editing while maintaining the structure of json.

  • support
  • support order retenation ( minimal change )
  • support comment (jsonc)
Warning

unsupport json5

Usage

import { parse } from "jsr:@gunseikpaseri/perfect-json-parser";

const jsonFile = `
{
  "hoge": "fuga"
}
`;

const parsed = parse(jsonFile);

parsed.edit(["hoge"], "piyo");

const editedJson = parsed.stringify();

console.log(editedJson);
//{
//  "hoge": "piyo"
//}

Internals

chevrotain is used for parsing. Syntax diagram can be seen from json_sytax_diagram.html

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@gunseikpaseri/perfect-json-parser

Import symbol

import * as perfect_json_parser from "@gunseikpaseri/perfect-json-parser";

---- OR ----

Import directly with a jsr specifier

import * as perfect_json_parser from "jsr:@gunseikpaseri/perfect-json-parser";

Add Package

npx jsr add @gunseikpaseri/perfect-json-parser

Import symbol

import * as perfect_json_parser from "@gunseikpaseri/perfect-json-parser";

Add Package

yarn dlx jsr add @gunseikpaseri/perfect-json-parser

Import symbol

import * as perfect_json_parser from "@gunseikpaseri/perfect-json-parser";

Add Package

pnpm dlx jsr add @gunseikpaseri/perfect-json-parser

Import symbol

import * as perfect_json_parser from "@gunseikpaseri/perfect-json-parser";

Add Package

bunx jsr add @gunseikpaseri/perfect-json-parser

Import symbol

import * as perfect_json_parser from "@gunseikpaseri/perfect-json-parser";