Subject JSON Objects in Array
From Rudolf Israel <risrael@web.de>
Date Mon, 03 Feb 2020 04:01:45 -0500
Newsgroups xb2net

Hello Boris


I would like to create the following JSON string for the transfer to the server:

{
"syncData":{
"sd_products":{
"serverData":"true",
"selectLimit": 3
},
"sd_customers":{
"serverData":"true",
"selectLimit": 3
}
}
}


I created the following source code with XB2Net:

oJSONSyncData := xbJSON():new()  
oJSONProducts := xbJSON():new()
oJSONCustomers := xbJSON():new()
aSyncDataPos := {}  

oProductsPos := xbJSON():new()
oProductsPos:AddVar("serverData","true")
oProductsPos:AddVar("selectLimit",3)
oJSONProducts:AddVar("sd_products",oProductsPos)
aadd(aSyncDataPos,oJSONProducts)

oCustomersPos := xbJSON():new()
oCustomersPos:AddVar("serverData","true")
oCustomersPos:AddVar("selectLimit",3)
oJSONCustomers:AddVar("sd_customers",oCustomersPos)
aadd(aSyncDataPos,oJSONCustomers)  

oJSONSyncData:AddVar("syncData",aSyncDataPos)


The result of what I then transfer to the server with the Execute method looks like this::
{
"syncData":[{
"sd_products":{
"serverData":"true",
"selectLimit": 3}
},
{"sd_customers":{
"serverData":"true",
"selectLimit": 3
}
}
]}


XB2Net therefore puts additional brackets around the array.
As a result, the result from the server is incorrect or empty.
What am I doing wrong ?

Thanks in advance

Rudi Israel


Recent messages in this thread
 
-# JSON Objects in Array (Current message) Rudolf Israel 03-Feb-2020 04:01 am
.-# Re: JSON Objects in Array Adrian B 03-Feb-2020 10:43 am
..|# Re: JSON Objects in Array Rudolf Israel 09-Feb-2020 07:35 am
..\# Re: JSON Objects in Array Rudolf Israel 09-Feb-2020 07:35 am