NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Thys on April 19, 2017, 10:04:09 AM

Title: NetWebServiceMethod - change JSON reply type
Post 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
Title: Re: NetWebServiceMethod - change JSON reply type
Post by: Thys on April 20, 2017, 01:17:04 AM
An embed point per parameter after the append statement can definitely be helpful please...
Title: Re: NetWebServiceMethod - change JSON reply type
Post by: Bruce on May 07, 2017, 11:05:05 PM
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

Title: Re: NetWebServiceMethod - change JSON reply type
Post by: Thys on May 08, 2017, 01:14:59 AM
Thanks Bruce, looking forward to the new build.
Title: Re: NetWebServiceMethod - change JSON reply type
Post by: Bruce on May 08, 2017, 06:59:07 AM
It's up.
update jFiles at the same time.

cheers
Bruce
Title: Re: NetWebServiceMethod - change JSON reply type
Post by: Thys on May 15, 2017, 04:04:32 AM
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
Title: Re: NetWebServiceMethod - change JSON reply type
Post by: Thys on May 15, 2017, 04:29:56 AM
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
Title: Re: NetWebServiceMethod - change JSON reply type
Post by: Bruce on May 16, 2017, 04:11:56 AM
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
Title: Re: NetWebServiceMethod - change JSON reply type
Post by: Thys on May 16, 2017, 09:52:53 PM
Thanks, looks good now.