Hi All,
I've come up against an issue in REST services/creating JSON templates. Eclipse tell me that REST services/JSON templates currently do not support boolean or double data types and can only pass string values (enclosed in " ") - Apparently there is no way around this and it will be addressed in the next release.
I'm just wondering if anyone else has encountered this issue and has managed to find a way around it?
Thanks in advance
Gina
Proclaim REST Services / JSON templates
Re: Proclaim REST Services / JSON templates
Hi,
it works if you do the json parsing in maths
e.g.
then in LA/Maths: (pseudocode):
it works if you do the json parsing in maths
e.g.
Code: Select all
{
"myBool":true,
"myDouble":1.23
}
Code: Select all
# Call rest, localise the response and convert to json obj
RESTSERVICE ("TEST01","test01","op-EntityString")
JSON-OBJECT-FROMFILE( json , op-EntityString )
#
# or construct from local json file
JSON-OBJECT-FROMFILE( json , "c:\temp\test.json" )
#
# grab values to local variables
v1 = JSON-GET-PROPERTY( json , "myBool" )
v2 = JSON-GET-PROPERTY( json , "myDouble" )
#
# convert to option y/n and Decimal
IF v1 = "true" THEN
PUT( "yes" , {temp option yn.Code} )
ELSE
PUT( "no" , {temp option yn.Code} )
END
#
# TODO for the decimal: sanity check valid chars - must only be numeric chars + fullstop and begin with a number
# e.g https://www.proclaimforum.co.uk/viewtopic.php?t=245
PUT( v2 , {temp value.Value} )
MESSAGE( "option: " , {temp option yn.Code} , NEWLINE , "value: " , {temp value.Value} )
-
- Posts: 2
- Joined: Wed Mar 31, 2021 8:40 am
Re: Proclaim REST Services / JSON templates
Thanks Steve, this is really helpful
I'm guessing this approach would only work for parsing the json response and not constructing the request? The request I'm sending has a mandatory boolean & double and fails if I construct the request within a proclaim json template. (due to the "")
I can't think of an easy way to construct a json request / file using maths. Although messy, I could potentially use string manipulation to create the request content, but can't figure out a way of creating the actual .json file for the rest service to send.
Thanks
Gina

I'm guessing this approach would only work for parsing the json response and not constructing the request? The request I'm sending has a mandatory boolean & double and fails if I construct the request within a proclaim json template. (due to the "")
I can't think of an easy way to construct a json request / file using maths. Although messy, I could potentially use string manipulation to create the request content, but can't figure out a way of creating the actual .json file for the rest service to send.

Thanks
Gina
Re: Proclaim REST Services / JSON templates
Ah, outbound fields, hmm I can't see how to override those sorry, other than some hacky external proxy webservice that rewrites the request.
https://stackoverflow.com/questions/301 ... ipt-object
You've probably tried, but out of curiosity I tried to create the json object in Maths and add it to a template, but too fails
then add this to a json template (your service would rely on a nested structure), but it fails:
https://stackoverflow.com/questions/301 ... ipt-object
You've probably tried, but out of curiosity I tried to create the json object in Maths and add it to a template, but too fails
Code: Select all
result = CHR( 123 ) + CHR( 34 ) + "myBool" + CHR( 34 ) + ": true " + CHR( 125 )
Code: Select all
{
"data": "{\"myBool\": true }"
}
-
- Posts: 471
- Joined: Fri Jun 15, 2012 12:44 pm
- Has thanked: 15 times
- Been thanked: 48 times
Re: Proclaim REST Services / JSON templates
We've experienced the same issue. Thankfully an internally created REST service so could code around it outside of Proclaim. It will need to be sorted by Eclipse for the up coming PI reforms as they're restful I am lead to believe.