NetTalk Central

Author Topic: NetWebServiceMethod - JSONClass question  (Read 5019 times)

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
NetWebServiceMethod - JSONClass question
« 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

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Re: NetWebServiceMethod - JSONClass question
« Reply #1 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