1.3.0 • Published 4 months ago

jsonc-parse v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

jsonc-parse

✨ Features

  • ESM Support
  • Tree Shakeable
  • Lightweight

📦 Installation

npm install jsonc-parse

📚 Usage

import { parse, parseFile, parseFileSync } from "jsonc-parse"

// From file async
const jsonCFile = await parseFile("./config.jsonc")

// From file
const jsonCFile = parseFileSync("./config.jsonc")

// From string
const jsonC = parse(`{
  "bar": "foo",
  // This is a comment.
  "foo": /* This is also a comment */ "bar",
}`)

you can also just import the strip function to remove comments from a string.

import { strip } from "jsonc-parse/strip"

// or
import { strip } from "jsonc-parse"

const json = strip(`{
  "bar": "foo",
  // This is a comment.
  "foo": /* This is also a comment */ "bar",
}`)
JSON.parse(strip(json)) // { bar: "foo", foo: "bar" }

📄 License

Published under MIT License.

1.3.0

4 months ago

1.2.0

6 months ago

1.1.0

7 months ago

1.0.4

9 months ago

1.0.3

12 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago