Help us shape the future of Go! Take the 2026 Go Developer Survey

jsonclose

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package jsonclose closes truncated JSON documents: the state machine both the OutputDecoder's prefix salvage (partial_json.go) and mw.RepairJSON need. It lived as two hand-maintained copies until the 2026-09-22 0.3.0 review flagged that they had already drifted (the trailing-comma rule differed), and moves here rather than into either public package — THE-END-GOAL principle 3 names internal/ as the tool that keeps the guaranteed surface small, and Go's path-based internal rule lets both the root package and mw import it while third parties cannot (the adapterkit precedent).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(s string) (closed string, valid bool)

Close returns s closed over its open strings and brackets — structure only, never value content: a dangling escape is fixed so it cannot eat the closing quote, trailing commas are dropped, and a dangling colon gets a null. The attempt is handed back even when it still is not valid JSON (mw's payload-preservation rule: the bytes the caller sent survive byte-for-byte); valid reports whether it is.

func OpenString added in v0.18.1

func OpenString(s string) bool

OpenString reports whether s ends inside an open string — Close's own reading of it, so what follows the last quote is the string's content (mw.RepairJSON trims Unicode whitespace there only when it is not).

Types

This section is empty.

Jump to

Keyboard shortcuts

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