Written by

Question Avi Luzon · Nov 1, 2023

set Property name

hi

we have a rest API that that on of the JSON object contain Property name "verify.facePosition"

we try to translate the JSON file to object with the function ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject()

how can we define the Property to "verify.facePosition" As %Boolean in the class ? 

i know that with underscore i can define the property with quotation marks like this - Property "verify_facePosition" As %Boolean

thanks for the help 

Product version: Caché 2016.1

Comments

Avi Luzon  Nov 2, 2023 to Flávio Lúcio Naves Júnior

Ok, using Rest Api I'm posting a request and getting an answer According to the data I posted. for example the request body looks like that:

{

"details":{

"id":"123456789",

"firstName":"bob",

"lastName":"bond",

}

}

The class Properties looks like that:

Property id As %Integer [ Required ];

Property firstName As  %String [ Required ];

Property lastName As  %String [ Required ];

And in the response I'm getting the details about this client. So far so good.

So now I need to send the request body like that:

{

"details":{

" client.id":"123456789",

"client.firstName":"bob",

"client.lastName":"bond",

}             

}

And I can't write properties with a dot:

Property client.id As %Integer [ Required ];

Property client.firstName As  %String [ Required ];

Property client. lastName As  %String [ Required ];

How can I fix this?

0
Robert Cemper  Nov 2, 2023 to Avi Luzon

try this dirty hack:

  • create your JSON object using "_"  
    • Property "client._id" As %Integer [ Required ];
    • Property "client_firstName" As  %String [ Required ];
    • Property "client_lastName" As  %String [ Required ];
  • create your JSON_body = { "details":{ ....} }
  • before sending use $TRanslate(JSON_body,"_",".")
0