Bun

namespace

JSONC

namespace JSONC

JSONC related APIs

  • function parse(
    input: string
    ): unknown;

    Parse a JSONC (JSON with Comments) string into a JavaScript value.

    Supports both single-line (//) and block comments (/* ... */), as well as trailing commas in objects and arrays.

    @param input

    The JSONC string to parse

    @returns

    A JavaScript value

    const result = Bun.JSONC.parse(`{
      // This is a comment
      "name": "my-app",
      "version": "1.0.0", // trailing comma is allowed
    }`);