dec_pjson_ '{"bool":true}'
┌────┬─┐
│bool│1│
└────┴─┘
We can check the datatype of the 1 and see that decode made it a boolean datatype.
datatype each dec_pjson_ '{"bool":true}'
┌───────┬───────┐
│literal│boolean│
└───────┴───────┘
However when encoding that json object from the decode it leaves it as an integer 1
enc_pjson_ dec_pjson_ '{"bool":true}'
{
"bool":1
}
I didn’t see the code for this on the jsoftware site. Chris Burke has a version of this and it seems in the “enc” verb there just needs to be a function “isbool” patterned after “isfloat” and then added to the case statement where the datatypes are processed
isfloat=: 8=3!:0
isbool=: 1=3!:0
.
.
.
if. 1<#$y do. if. isboxed y do. enc_dict y else. bk sep <@enc"_1 y end. elseif. isboxed y do. bk sep enc each y elseif. ischar y do. if. ESS = {. y do. }. y return. end. enc_char y elseif. isfloat y do. enc_num y elseif. isbool y do.
if. y do.
'true'
else.
'false'
end. elseif. do. enc_int y end.
I changed my local copy of pjson.ijs and it seems to work.
I didn’t see where this code was on the JSoftare Git site and I’ve never messed with the repository directly
Tom McGuire