0
I want to change a field in json from number to string format.
I create the json output from a dynamical created text file like this:
LastUpdate=2019-12-01T13:26:46.388817319+01:00
State=NOT OK
TempA=26.299999
TempB=-0.100000
PumpState=0
Vault=100.000000
Mode=H+WW
ErrState=0
then I use jo
to convert this output to json
cat /tmp/file | jo -p
{
"LastUpdate": "2019-12-01T13:26:46.388817319+01:00",
"State": "NOT OK",
"TempA": 26.299999,
"TempB": -0.1,
"PumpState": 0,
"Vault": 100,
"Mode": "H+WW",
"ErrState": 0
}
Problem is, that I need the value ErrState
to be in string format.
It looks like jo
cant do it on piped input. So I was thinking it is maybe possible with sed
or jq
? Or any other tool?
Problem could be, that Output from ErrState can change to text, than I will have two times quotes on a simple search & replace.
Remember I want to keep the full output - only change ErrState to string.
hmm.. not bad - but it change 0 to null – Thomas – 2019-12-01T13:45:29.900
ok, only on the only version from jq play - in the script that works THANKS :) – Thomas – 2019-12-01T13:48:13.663
edit: online version from jq play ;) – Thomas – 2019-12-01T13:55:19.543