Closed hongz1 closed 4 years ago
numeric should just set the number using the UDOSetProperty RET = UDOSetProperty(TESTHANDLE, "CODE", 1234)
For Binary use the UDO_TRUE or UDO_FALSE keywords. RET = UDOSetProperty(TESTHANDLE, "BINARY_T", UDO_TRUE) RET = UDOSetProperty(TESTHANDLE, "BINARY_F", UDO_FALSE)
Output from a sample program: { "CODE": 1234, "BINARY_T": 1, "BINARY_F": 0 }
try this if you want to output boolean true, false, null value: RET = UDOCreate(UDO_TRUE, true_node) RET = UDOSetProperty(TESTHANDLE, "BOOLEAN_T", true_node)
Thank you for the answers. I noticed that the UDO automatically double quotes into the value if the variable is string type (smart!). For boolean flag, thank you jmao-rs! Yes, I had to create type object first.
here is my testing:
$INCLUDE UNIVERSE.INCLUDE UDO.H *
MAINLINE:
* NUM = '12345' STATUS = UDOCreate(UDO_OBJECT, UDOHANDLE) STATUS = UDOSetProperty(UDOHANDLE, "number1", NUM) NUM += 0 STATUS = UDOSetProperty(UDOHANDLE, "number2", NUM) STATUS = UDOCreate(UDO_TRUE,TRUE.VAL) STATUS = UDOSetProperty(UDOHANDLE, "boolean", TRUE.VAL) STATUS = UDOWrite(UDOHANDLE, UDOFORMAT_JSON, JSON.OUTPUT) STATUS = UDOFree(UDOHANDLE) PRINT JSON.OUTPUT RETURN
[OUTPUT] { "number1": "12345", "number2": 12345, "boolean": true }
I am trying to figure out how to set boolean and number types of values something like
{ "code": 1234, "isUser": true }
Is there a way to write JSON with specific types or I have to write string values?