Skip to main content
Module

x/aleph/server/deps.ts>jsonc.parse

The Full-stack Framework in Deno.
Very Popular
Latest
function jsonc.parse
import { jsonc } from "https://deno.land/x/aleph@1.0.0-beta.44/server/deps.ts";
const { parse } = jsonc;

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

Examples

Example 1

import * as JSONC from "https://deno.land/std@0.224.0/jsonc/mod.ts";

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

Parameters

text: string

A valid JSONC string.

optional
unnamed 1: ParseOptions = [UNSUPPORTED]