Skip to content

v1.4.0 — 9 new APIs, 20 issues resolved

Choose a tag to compare

@buger buger released this 28 Jul 10:29

New APIs (all backward-compatible)

Iteration with error/break control

  • ArrayEachErr — like ArrayEach but the callback returns error. Return io.EOF for graceful stop, any other error to abort. Resolves #53, #129, #176, #230, #255, #262.
  • EachKeyErr — same pattern for EachKey.

Safe string handling

  • Escape(s string) []byte — RFC 8259 string escaping (inverse of Unescape). Produces a quoted JSON string literal.
  • SetString(data, val, keys...)Set with auto-quoted value. No more invalid JSON from forgetting quotes. Resolves #144, #158, #218, #270.

Container accessors

  • GetArrayLen(data, keys...) (int, error) — count array elements without a callback. Resolves #175, #261.
  • GetObjectLen(data, keys...) (int, error) — count object key-value pairs.
  • GetUint64(data, keys...) (uint64, error) — uint64 variant of GetInt. Resolves #271.

Delete found signal

  • DeleteFound(data, keys...) ([]byte, bool) — returns whether the key was found. Resolves #229.

Wildcard paths

  • EachKeyWildcard, ArrayEachWildcard, SetWildcard[*] path component to iterate/set all elements. Resolves #112.
    jsonparser.SetWildcard(data, []byte("true"), "users", "[*]", "active")

JSONPath compiled paths

  • ParsePath("$.users[0].name")[]string{"users", "[0]", "name"}
  • CompilePath + CompiledPath — pre-compile and reuse with Get/Set/Delete/etc. Resolves #234, #251.
    path, _ := jsonparser.CompilePath("$.person.name.fullName")
    name, _ := path.Get(data)  // reuse across calls

Fixes

  • EachKey no longer panics with >64 key components (#56)
  • Set pre-allocates output buffer, reducing allocations from 6 to 1 (#107)

Proof coverage

  • 3 new SYS-REQs (112: container length, 113: wildcard paths, 114: compiled paths)
  • 121 total requirements, 0 errors, 0 warnings, 384 MC/DC witness rows (0 uncovered)
  • All new APIs traced via source-native annotations

Acknowledgments

Implemented by codex (gpt-5-codex) via codex exec. Proof coverage by ReqProof.

Full changelog: CHANGELOG.md