Skip to main content
Home

@std/jsonc@1.0.2
Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score100%
Downloads5,776/wk
Published10 months ago (1.0.2)

Parsing and serializing of JSONC files

function parse
parse(text: string): JsonValue

Converts a JSON with Comments (JSONC) string into an object.

Examples

Usage

import { parse } from "@std/jsonc";
import { assertEquals } from "@std/assert";

assertEquals(parse('{"foo": "bar"}'), { foo: "bar" });
assertEquals(parse('{"foo": "bar", }'), { foo: "bar" });
assertEquals(parse('{"foo": "bar", } /* comment *\/'), { foo: "bar" });

Parameters

A valid JSONC string.

Return Type

JsonValue

The parsed JsonValue from the JSONC string.

Throws

SyntaxError

If the JSONC string is invalid.

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:@std/jsonc

Import symbol

import { parse } from "@std/jsonc";
or

Import directly with a jsr specifier

import { parse } from "jsr:@std/jsonc";