NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Thys on April 19, 2017, 10:04:09 AM
-
Hi,
I have a string variable as a return value in a web service method that returns JSON. Under certain conditions I would like this value not to contain string quotes around it in the JSON result. I see that in the generated code when I change
jsonResults.append('content',p_web.AsciiToUtf(REG:content),json:String)
to
jsonResults.append('content',p_web.AsciiToUtf(REG:content),json:Literal)
the string quotes are not added. How can this be done without changing the generated code?
Thanks
-
An embed point per parameter after the append statement can definitely be helpful please...
-
I sense you have an OMIT statement in the gleam of your eye....
Incidentally json:literal would not be the right equate to use there, rather you'd want one of
json:String EQUATE(1) !json literal types
json:Numeric EQUATE(2)
json:Object EQUATE(3)
json:Array EQUATE(4)
json:Boolean EQUATE(5)
json:Nil EQUATE(6)
or a new one;
json:Auto EQUATE(7)
the last one selects an appropriate type based on the contents of the value.
I've added a template setting to the "Field" and "StringTheory" types though for build 9.27 though.
cheers
Bruce
-
Thanks Bruce, looking forward to the new build.
-
It's up.
update jFiles at the same time.
cheers
Bruce
-
Hi Bruce.
I installed 9.27 today. See attached - there is only one option in the "JSON type" drop list. Is that correct? If so, what purpose does the drop list have with only one option?
Thys
-
Bruce,
I also now get this prototype error - see attached.I saw that the last parameter is just "Auto", I changed the source to "json:auto" but it seems like the method override doesn't exist.
Thys
-
in Netweb.tpw
line circa 18686
replace the line
#Prompt('JSON type',DROP('String,Numeric,Object,Array,Boolean,Null,Auto')),%MethodReturnJsonType,default('String')
with
#Prompt('JSON type',DROP('String|Numeric|Object|Array|Boolean|Null|Auto')),%MethodReturnJsonType,default('String')
repeat for line 18691
sorry about that - fixed for the next build.
Bruce
-
Thanks, looks good now.