Don't interpret data in ##class(%DynamicAbstractObject).%FromJSON(src)
Hi All,
See code below. We don't want to %FromJSON interpret the data.
We're creating a method to convert json to csv but we don't want to convert/interpret any of the data
The write in the code snipped below will give 220 as weight instead of 220.00.
Does anyone now a way/method to don't interpret the data without put "" on the values?
Class Tmp.test
{
ClassMethod help()
{
set src = "{""name"" : ""greg"", ""weight"" : 220.00 }"set obj = ##class(%DynamicAbstractObject).%FromJSON(src)
write obj.name,!
write obj.weight,!
return$$$OK
}
}Product version: IRIS 2021.2
$ZV: IRIS for Windows (x86-64) 2021.2 (Build 649U) Thu Jan 20 2022 08:46:32 EST [HealthConnect:3.4.0] [HealthConnect:3.4.0]
Discussion (2)1
Comments
ClassMethod help(){
set src = "{""name"" : ""greg"", ""weight"" : 220.00 }"
set obj = ##class(%Library.DynamicObject).%FromJSON(src)
write obj.%Get("name",,"string"),!
write obj.%Get("weight",,"string"),!
return $$$OK}Output:
USER>Do ##class(Test.DynaNumString).help() greg 220.00
Hi Alex,
Great, thank you for the quick reply.
I was wrong with my idea. The %FromJSON is not the problem but the way I get it from the DynamicObject.
Menno