https://pkg.go.dev/encoding/json#Indent:

[...] trailing space characters at the end of src are preserved and copied to dst. For example, if src has no trailing spaces, neither will dst; if src ends in a trailing newline, so will dst.

When GOEXPERIMENT=jsonv2, encoding/json.Indent no longer preserves trailing whitespace, contrary to the documentation.

Comment From: mrkfrmn

I'll also CC @dsnet for this.

Comment From: dsnet

That's fun. #13520 says this behavior is unfortunate, but we're just going to need to preserve the behavior 😆

Comment From: gopherbot

Change https://go.dev/cl/692195 mentions this issue: encoding/json: fix Indent trailing whitespace regression in goexperiment.jsonv2