I originally discovered this problem in B4J and reproduced in B4A.
Steps to reproduce the problem: Run the included code in either B4A or B4J.
Steps to reproduce the problem: Run the included code in either B4A or B4J.
test example:
'capitalized keyname: Test
Dim strJson As String=$"[{"orderitem_id":"1","order_id":"1","qty":"1","amt":"15","Test":"1"},
{"orderitem_id":"2","order_id":"1","qty":"2","amt":"20","Test":"1"}]"$
test(strJson) 'Test=null while 1 is expected
'lowercase key name: test
strJson=$"[{"orderitem_id":"1","order_id":"1","qty":"1","amt":"15","test":"1"},
{"orderitem_id":"2","order_id":"1","qty":"2","amt":"20","test":"1"}]"$
test(strJson) 'Test=1 as expected
B4X:
Private Sub test(strJson As String)
Dim parser As JSONParser
'parser.Initialize($"${J.GetString}"$)
parser.Initialize($"${strJson}"$)
LogDebug("strJson=" & strJson)
Dim lstResult As List
lstResult.Initialize
Try
lstResult=parser.NextArray
Catch
Log(LastException)
Return
End Try
For Each m As Map In lstResult 'ignore
'go throught each record
'''''''
Log("***: " & m & " ***")
Dim msg As String=$"orderItem_id=${m.Get("orderitem_id")}"$
Log(msg)
msg=$"qty=${m.Get("qty")}"$
Log(msg)
msg=$"amt=${m.Get("amt")}"$
Log(msg)
msg=$"Test=${m.Get("test")}"$
Log(msg)
Next
End Sub