Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fresh/tests/deps.ts>JSONC.parse

The next-gen web framework.
Extremely Popular
Go to Latest
function JSONC.parse
import { JSONC } from "https://deno.land/x/fresh@1.6.1/tests/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]