jsonc

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package jsonc converts JSONC (JSON with comments and trailing commas, the dialect VS Code uses for devcontainer.json) into plain JSON that encoding/json accepts.

Strip replaces every comment byte and every trailing comma with a space rather than deleting it, so byte offsets are preserved: a json.SyntaxError reported against the stripped output still points at the right position in the original source.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Strip

func Strip(src []byte) ([]byte, error)

Strip returns src with // line comments, /* block */ comments, and trailing commas (a comma before a closing } or ]) replaced by spaces. Comments and commas inside string literals are left untouched. The returned slice has the same length as src.

It returns an error only for an unterminated string or block comment; malformed JSON that is otherwise lexically closed is left for the JSON parser to report.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL