NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Thys on July 20, 2018, 02:08:37 AM

Title: NetWebServiceMethod - JSONClass question
Post by: Thys on July 20, 2018, 02:08:37 AM
Hi,

In a webservice method, I want to append a JSON object to the JSON response. But the resultant object is not properly formatted.

Here is the code where the JSON object is added to the response:

           st.SetValue (result)
           js.Start ()
           js.Load (st)
           jsonResults.Append (js)


Here is the JSON that is returned:

{   
   "utQuery_response":
      {
         {
            "list":[{"ClientNo":453,"Name":"Mondi"},{"ClientNo":732,"Name":"Meyersdal Shopping Centre"}]
         }
      }
}


The problem seems to be the extra pair of curly bracket being added when js is appended to jsonResults. Is there a property to be set on js that would prevent this?

Thanks,
Thys
Title: Re: NetWebServiceMethod - JSONClass question
Post by: Thys on July 22, 2018, 09:29:33 PM
Slight focus shift - the following (simpler) code got it fixed for me:

   st.SetValue (result)
   jsonResults.Load (st)


Seems like the JSON header boundary is only added after "Before call to json.save". Works well now.

{
    "utQuery_response": {
        "list": [
            {
                "ClientNo": 453,
                "Name": "Mondi"
            },
            {
                "ClientNo": 732,
                "Name": "Meyersdal Shopping Centre"
            }
        ]
    }
}


Thys