From 4ab1155a695a1614db809405d75a01d2285dc788 Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Tue, 18 Aug 2026 12:04:57 +0100 Subject: [PATCH 1/2] fix(jsonview): use literal object keys in pretty output --- internal/jsonview/staticdisplay.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/jsonview/staticdisplay.go b/internal/jsonview/staticdisplay.go index 239562f..b5dd1e8 100644 --- a/internal/jsonview/staticdisplay.go +++ b/internal/jsonview/staticdisplay.go @@ -100,10 +100,11 @@ func formatJSONObject(result gjson.Result, indent, width int) string { if len(keys) == 0 { return nullValueStyle.Render("(empty)") } + values := result.Map() var items []string for _, key := range keys { - value := result.Get(key.Str) + value := values[key.Str] keyStr := getIndent(indent) + keyStyle.Render(sanitizeTerminalString(key.Str)+":") // If item will be a one-liner, put it inline after the key, otherwise // it starts with a newline and goes below the key. From a3d4e7b9f3620b70fff1f0e3d7574432763c25cd Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Tue, 18 Aug 2026 12:05:05 +0100 Subject: [PATCH 2/2] test(jsonview): cover dotted literal keys --- .../staticdisplay_literal_keys_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 internal/jsonview/staticdisplay_literal_keys_test.go diff --git a/internal/jsonview/staticdisplay_literal_keys_test.go b/internal/jsonview/staticdisplay_literal_keys_test.go new file mode 100644 index 0000000..d2d965c --- /dev/null +++ b/internal/jsonview/staticdisplay_literal_keys_test.go @@ -0,0 +1,18 @@ +package jsonview + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/tidwall/gjson" +) + +func TestStaticDisplayUsesLiteralObjectKeys(t *testing.T) { + t.Parallel() + + result := gjson.Parse(`{"a.b":"literal-value","a":{"b":"nested-value"}}`) + out := formatJSON(result, 80) + + require.Contains(t, out, "literal-value") + require.Contains(t, out, "nested-value") +}