Fix json parser (#80)

* fix #77: parse floats and nils as well and convert them to string
This commit is contained in:
T.v.Dein
2025-10-06 22:54:31 +02:00
committed by GitHub
parent 8c87da34f2
commit 35b726fee4
3 changed files with 62 additions and 1 deletions

View File

@@ -180,6 +180,38 @@ func TestParserJSONInput(t *testing.T) {
expect: Tabdata{},
},
{
// contains nil, int and float values
name: "niljson",
wanterror: false,
input: `[
{
"NAME": "postgres-operator-7f4c7c8485-ntlns",
"READY": "1/1",
"STATUS": "Running",
"RESTARTS": 0,
"AGE": null,
"X": 12,
"Y": 34.222
}
]`,
expect: Tabdata{
columns: 7,
headers: []string{"NAME", "READY", "STATUS", "RESTARTS", "AGE", "X", "Y"},
entries: [][]string{
[]string{
"postgres-operator-7f4c7c8485-ntlns",
"1/1",
"Running",
"0",
"",
"12",
"34.222000",
},
},
},
},
{
// one field missing + different order
// but shall not fail