Hi everyone;
I'm having a rough time posting a particular JSON object. The JSONParser works perfectly, but when the resulting map is posted, the quotes for the array type and JSON type end up in the wrong place, breaking the object.
The log result is here:
I'm having a rough time posting a particular JSON object. The JSONParser works perfectly, but when the resulting map is posted, the quotes for the array type and JSON type end up in the wrong place, breaking the object.
B4X:
Sub btnSend_Click
'****************************************************************************
'Send a POST request
Dim Map1 As Map
Dim JSON As JSONParser
Dim Jout As JSONGenerator
Dim jsonString As String
JSON.Initialize($"{"address":["123412341234123"],
"senderAddress":"wombat",
"outboundSMSTextMessage":{"message":"OFF"},
"ClientCorrelator":"123456",
"senderName":"AFTestClient"}
"$)
Map1.Initialize
Map1 = JSON.NextObject
Jout.Initialize(Map1)
jsonString=Jout.ToString
Log(jsonString)
job1.PostMultipart($"HTTP://dweet.io/dweet/for/WombatStatus"$, Map1, Null)
job1.GetRequest.SetHeader("Content-Type", "application/json")
The log result is here:
{"address":["123412341234123"],"senderAddress":"wombat","outboundSMSTextMessage":{"message":"OFF"},"ClientCorrelator":"123456","senderName":"AFTestClient"}
JobName = Job1, Success = true
{"this":"succeeded","by":"dweeting","the":"dweet","with":{"thing":"WombatStatus","created":"2019-12-21T13:11:04.980Z","content":
{"address":"[123412341234123]","senderAddress":"wombat","outboundSMSTextMessage":"{message=OFF}","ClientCorrelator":123456,"senderName":"AFTestClient"},"transaction":"53168ea6-5309-4bda-80e8-e02a71f1bbb5"}}
The array object has the quotes outside of the bracket, and the embedded JSON message object no longer surrounds the values with quotes.JobName = Job1, Success = true
{"this":"succeeded","by":"dweeting","the":"dweet","with":{"thing":"WombatStatus","created":"2019-12-21T13:11:04.980Z","content":
{"address":"[123412341234123]","senderAddress":"wombat","outboundSMSTextMessage":"{message=OFF}","ClientCorrelator":123456,"senderName":"AFTestClient"},"transaction":"53168ea6-5309-4bda-80e8-e02a71f1bbb5"}}