Catmandu
Catmandu copied to clipboard
is_string conditional and number strings
{ "number" : 123 }
{ "number" : "123"}
if is_string("number")
add_field("test","true")
end
The is_string conditional is not recognizing the second variation of numbers as string.
Is this by intention, if so this should be documented.
How is it possible to check if a number string is a string?
Hi, this is not the intention. Can you provide some context on the version of Catmandu?
With
if is_string(test)
add_field(ok,0)
else
add_field(ok,1)
end
and Catmandu 1.2016 this works for me:
$ echo '{"test":"123"}' | catmandu convert --fix ~/Desktop/TMP/brol.fix
[{"test":"123","ok":"1"}]
$ echo '{"test":123}' | catmandu convert --fix ~/Desktop/TMP/brol.fix
[{"ok":"1","test":123}]
$ echo '{"test":"1a23"}' | catmandu convert --fix ~/Desktop/TMP/brol.fix
[{"test":"1a23","ok":"0"}]