JSON - is this a bug??
Hi All
I'm sharing this ticket just posted to wrc as I believe it is inconsistent behaviour. and other developers may trip over it....
<wrc ticket>
I have found something that appears to me to be inconsistent
Simple example
set x={"theValue":true} write x.theValue
this correctly converts true to 1
However if " (double quotes are placed around it
eg
set x={"theValue":"true"} write x.theValue
it does not convert and displays the string "true"
!!!!!
</wrc ticket>
Peter
And it works exactly as it should be. I the first example it as a Boolean, and next as a string. What would you do if you would need literal "true", if it would converted to Boolean all the time?
Hi Dimitry
But still inconsistent
eg
set x={"TheValue":"123"} write x.TheValue
Does not return a quoted string
Peter
Hi Demitri
It's me!!!!
I thought javascript was doing something different
if (oJSON.theValue) { write("hello") }
I *thought* that it was evaluating it as a boolean
It's not - the test is showing if it's defined
So.....
Learnt something today
Thanks
Peter
Hey Herman
Glad to see that you are still around!!!!
Yup it's me - I was not understanding - see my reply above
Peter
Yes, it also works as expected, because
Outputs
Without any quotes, but it doesn't mean that there are no difference between "123" and just 123. You can see it if you would try to work with $zhex. Try by yourself
(still not herding sheep in Tuscany ;-))
How would you want to address a string with the value of "true" if there would be automatic translation to 1 ?
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue