Should Decimal be output as a number here or is there a reason Decimal is coming as a string? Where, Number and Real aren't?
Code:
Object oJSONTest is a cWebHttpHandler
Set psPath to "JSONTest"
Set psVerbs to "*"
Struct tJSONTest
String sAString
Decimal dADecimal
Number nANumber
Integer iAInteger
Real rAReal
End_Struct
Procedure OnHttpGet String sPath String sAcceptType
Forward Send OnHttpGet sPath sAcceptType
tJSONTest stJSONTest
Handle hoJSON
UChar[] ucResponse
Move "1.75" to stJSONTest.sAString
Move 1.75 to stJSONTest.dADecimal
Move 1.75 to stJSONTest.nANumber
Move 1 to stJSONTest.iAInteger
Move 1.75 to stJSONTest.rAReal
Get Create (RefClass(cJsonObject)) to hoJSON
Send DataTypeToJson of hoJSON stJSONTest
Get StringifyUtf8 of hoJSON to ucResponse
Send AddHttpResponseHeader "Content-Type" "application/json"
Send OutputUChar ucResponse
End_Procedure
End_Object
Returns
Code:
{
"sAString":"1.75",
"dADecimal":"1.75",
"nANumber":1.75,
"iAInteger":1,
"rAReal":1.75
}