Module

x/fresh/src/dev/deps.ts>JSONC.parse

The next-gen web framework.
Extremely Popular
Latest
function JSONC.parse
import { JSONC } from "https://dotland.deno.dev/x/fresh@1.7.3/src/dev/deps.ts";
const { parse } = JSONC;

Converts a JSON with Comments (JSONC) string into an object. If a syntax error is found, throw a {@link SyntaxError}.

Examples

Example 1

import { parse } from "https://deno.land/std@$STD_VERSION/jsonc/mod.ts";

console.log(parse('{"foo": "bar", } // comment')); // { foo: "bar" }
console.log(parse('{"foo": "bar", } /* comment *\/')); // { foo: "bar" }
console.log(parse('{"foo": "bar" } // comment', {
  allowTrailingComma: false,
})); // { foo: "bar" }

Parameters

text: string

A valid JSONC string.

optional
unnamed 1: ParseOptions = [UNSUPPORTED]