iOS Question Adding two JSON strings.

CrownDeveloper

Member
Licensed User
Hi i have two JSON strings from master table and detail table from db.
now i want to add both JSON before sending to the server.
below is my code. How can i add or concatenate two JSON strings.

Dim oKeyValueList, mKeyValueList As List
oKeyValueList.Initialize
mKeyValueList.Initialize

'---Detail JSON
cursor1 = SQL1.ExecQuery("SELECT * FROM occupancy")
Do While cursor1.NextRow
oKeyValueList.Add(CreateMap("ID":cursor1.GetInt("ID"),"user":cursor1.GetString("user"),"project":cursor1.GetString("project"),"access":cursor1.GetString("access"),"occupancy":cursor1.Getint("occupancy"),"lat":cursor1.GetString("lat"),"lon":cursor1.GetString("lon"),"datetime":cursor1.GetLong("datetime")))

Loop


Dim oJSONString As String
Dim oJSONGenerator As JSONGenerator
oJSONGenerator.Initialize2(oKeyValueList)
oJSONString=oJSONGenerator.ToString

''---Master JSON
cursor1 = SQL1.ExecQuery("SELECT * FROM Master")
Do While cursor1.NextRow
mKeyValueList.Add(CreateMap("mID":cursor1.GetInt("ID"),"muser":cursor1.GetString("muser"),"mproject":cursor1.GetString("mproject")))

Loop


Dim mJSONString As String
Dim mJSONGenerator As JSONGenerator
mJSONGenerator.Initialize2(mKeyValueList)
mJSONString=mJSONGenerator.ToString

''--- Combine both JSON
Dim tJSONString As String
tJSONString = oJSONString & mJSONString ' What is the correct way to add two json.
 

CrownDeveloper

Member
Licensed User
Hi i have two JSON strings from master table and detail table from db.
now i want to add both JSON before sending to the server.
below is my code. How can i add or concatenate two JSON strings.
B4X:
Dim oKeyValueList, mKeyValueList As List
oKeyValueList.Initialize
mKeyValueList.Initialize

'---Detail JSON 
cursor1 = SQL1.ExecQuery("SELECT * FROM occupancy")
Do While cursor1.NextRow
oKeyValueList.Add(CreateMap("ID":cursor1.GetInt("ID"),"user":cursor1.GetString("user"),"project":cursor1.GetString("project"),"access":cursor1.GetString("access"),"occupancy":cursor1.Getint("occupancy"),"lat":cursor1.GetString("lat"),"lon":cursor1.GetString("lon"),"datetime":cursor1.GetLong("datetime"))) 

Loop


Dim oJSONString As String
Dim oJSONGenerator As JSONGenerator
oJSONGenerator.Initialize2(oKeyValueList)
oJSONString=oJSONGenerator.ToString

''---Master JSON
cursor1 = SQL1.ExecQuery("SELECT * FROM Master")
Do While cursor1.NextRow
mKeyValueList.Add(CreateMap("mID":cursor1.GetInt("ID"),"muser":cursor1.GetString("muser"),"mproject":cursor1.GetString("mproject")))

Loop


Dim mJSONString As String
Dim mJSONGenerator As JSONGenerator
mJSONGenerator.Initialize2(mKeyValueList)
mJSONString=mJSONGenerator.ToString

''--- Combine both JSON
Dim tJSONString As String
tJSONString = oJSONString & mJSONString
What is the correct way to add two json objects.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…