I'm trying to convert a B4A application into a B4I . A piece of code that works without problems in B4A gives me an error in B4I ... I can't figure out what's wrong ...
I can't post the code because it's too big, but I try to describe in words what I want to do:
I have a CustomListView in which each item contains a TextField, a Switch and 4 B4XPlusMinus. When creating each item in the CustomListView, a List with the initial and final value of each object in the panel is generated. Each change of the value of any object will be saved in the SavedList in NewVal.
The error appears on the line of code marked with ERROR HERE
Error occurred on line: 29 (setariJSON)
Invalid type in JSON write (_typesetare)
Before executing the line of code where it gives error, the values are as in the attached image.
I can't post the code because it's too big, but I try to describe in words what I want to do:
I have a CustomListView in which each item contains a TextField, a Switch and 4 B4XPlusMinus. When creating each item in the CustomListView, a List with the initial and final value of each object in the panel is generated. Each change of the value of any object will be saved in the SavedList in NewVal.
B4X:
'class setariJSON
Sub Class_Globals
Public IntrariDetail As List
End Sub
Public Sub Create As String
Dim m As Map
m.Initialize
Dim Map2 As Map
Map2.Initialize
Map2.Put("poz",IntrariDetail)
m.Put("intd", Map2 )
Dim JSONGenerator1 As JSONGenerator
JSONGenerator1.Initialize( m )
Dim jsonX As String
jsonX = ""
jsonX = JSONGenerator1.ToString <------------------ ERROR HERE!
Return jsonX
End Sub
B4X:
Sub Process_Globals
Type typeSetare (Den As String, NV As Object, OV As Object, idVal As Int)
Type listObject (idValue As Int, Denumire As String, NewVal As Object, OldVal As Object)
Public listObjects As listObject
Public SaveList As List
End Sub
.......
Sub CreatePanel....
Public lo1 As listObject
lo1.Initialize
lo1.idValue = idValue
lo1.Denumire = "ValName"
lo1.OldVal = m.Get("ValName")
lo1.NewVal = m.Get("ValName")
SaveList.Add(lo1)
End Sub
Sub Save
Dim e As setariJSON
e.Initialize
e.IntrariDetail.Initialize
For nr = 0 To SaveList.Size - 1
Dim x As typeSetare
x.Initialize
Dim y As listObject = SaveList.Get(nr)
x.Den = y.Denumire
x.NV = y.NewVal
x.OV = y.OldVal
x.idVal = y.idValue
e.IntrariDetail.Add(x)
Next
Dim JSONstring As String
JSONstring = e.Create
'send JSONstring to POST
End Sub
The error appears on the line of code marked with ERROR HERE
Error occurred on line: 29 (setariJSON)
Invalid type in JSON write (_typesetare)
Before executing the line of code where it gives error, the values are as in the attached image.