docs(jsonc): add module-level docs (#4402)

* docs(jsonc): add module-level docs

* Yoshiya's suggestion
This commit is contained in:
Asher Gomez 2024-02-28 06:28:34 +11:00 committed by GitHub
parent 4bcdea86d1
commit 3736b01a7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 4 deletions

View File

@ -1,4 +1,24 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
/**
* Provides tools for working with JSONC (JSON with comments). Currently, this
* module only provides a means of parsing JSONC. JSONC serialization is not
* yet supported.
*
* This module is browser compatible.
*
* @example
* ```ts Parsing JSONC
* import { parse } from "https://deno.land/std@$STD_VERSION/jsonc/mod.ts";
*
* parse('{"foo": "bar", } // comment'); // { foo: "bar" }
* parse('{"foo": "bar", } /* comment *\/'); // { foo: "bar" }
* parse('{"foo": "bar" } // comment', {
* allowTrailingComma: false,
* }); // { foo: "bar" }
* ```
*
* @module
*/
export * from "./parse.ts";

View File

@ -33,11 +33,11 @@ export interface ParseOptions {
* ```ts
* 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', {
* parse('{"foo": "bar", } // comment'); // { foo: "bar" }
* parse('{"foo": "bar", } /* comment *\/'); // { foo: "bar" }
* parse('{"foo": "bar" } // comment', {
* allowTrailingComma: false,
* })); // { foo: "bar" }
* }); // { foo: "bar" }
* ```
*
* @param text A valid JSONC string.