Skip to main content
Home

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
2 years 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

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

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

pnpm i jsr:@gunseikpaseri/perfect-json-parser
or (using pnpm 10.8 or older)
pnpm dlx jsr add @gunseikpaseri/perfect-json-parser

Import symbol

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

Add Package

yarn add jsr:@gunseikpaseri/perfect-json-parser
or (using Yarn 4.8 or older)
yarn dlx jsr add @gunseikpaseri/perfect-json-parser

Import symbol

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

Add Package

vlt install jsr:@gunseikpaseri/perfect-json-parser

Import symbol

import * as perfect_json_parser from "@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

bunx jsr add @gunseikpaseri/perfect-json-parser

Import symbol

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