Skip to content

Read and write JSON with encoding/json/v2 - #64

Merged
pscheid92 merged 1 commit into
mainfrom
json-v2
Nov 6, 2026
Merged

pscheid92 merged 1 commit into
mainfrom
json-v2

Conversation

@pscheid92

@pscheid92 pscheid92 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Moves the CLI to encoding/json/v2 (stable since Go 1.27).

  • --json output goes through a jsontext.Encoder with Deterministic, so keys stay sorted and each value is still one line. v2 doesn't escape HTML, so SetEscapeHTML(false) is removed.
  • Visible change: an empty file list now prints as [] instead of null.
  • API answers are read with UnmarshalRead, which also refuses data after the value. Names now match case-sensitively; every response struct already carries the server's exact names.
  • sharetest and the tests use v2 too.

Independent of secretli/server#53: the current server already sends exact names.

--json output goes through a jsontext.Encoder with Deterministic, so
keys stay sorted and each value ends its line as before; v2 escapes no
HTML, so SetEscapeHTML goes. One visible change: a file list that is
empty prints as [] instead of null.

API answers are read with UnmarshalRead, which also refuses trailing
data after the value. Field names now match case-sensitively; every
struct carries the server's exact names.
@pscheid92
pscheid92 merged commit b1a8f01 into main Nov 6, 2026
13 checks passed
@pscheid92
pscheid92 deleted the json-v2 branch November 6, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant