Module

std/jsonc/parse.ts>parse

Deno standard library
Go to Latest
function parse
import { parse } from "https://dotland.deno.dev/std@0.215.0/jsonc/parse.ts";

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@0.215.0/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]