Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_string conditional and number strings #393

Open
TobiasNx opened this issue Jul 15, 2022 · 1 comment
Open

is_string conditional and number strings #393

TobiasNx opened this issue Jul 15, 2022 · 1 comment

Comments

@TobiasNx
Copy link

TobiasNx commented Jul 15, 2022

{ "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?

@phochste
Copy link
Member

phochste commented Feb 8, 2023

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"}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants