miller icon indicating copy to clipboard operation
miller copied to clipboard

hex value exported into json, but json does not support hex literals

Open Ablu opened this issue 10 months ago • 0 comments

Taking:

> cat /tmp/i.csv
a,b
foo,0x123

I get:

> mlr --icsv --ojson cat /tmp/i.csv
[
{
  "a": "foo",
  "b": 0x123
}
]

But 0x123 is not a valid JSON value:

> mlr --icsv --ojson cat /tmp/i.csv | jq
jq: parse error: Invalid numeric literal at line 5, column 0

Tested with:

> mlr --version
mlr 6.13.0

One probably wants to either export it as base 10 number or as string:

[
{
  "a": "foo",
  "b": "0x123"
}
]

or:

[
{
  "a": "foo",
  "b": 291
}
]

Ablu avatar Feb 25 '25 16:02 Ablu