iOS Question Not possible to add Null value to map

red30

Well-Known Member
Licensed User
Longtime User
B4X:
Map.Put("temp",Null)
In B4i, it is not possible to add a Null value to a map. Why? It is possible in B4A and B4J, why can't I do it in B4i?
Next, this map is converted to json and some of the points must contain a null value (this is required by the server to which I send it), but I cannot do this in B4i ...
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
It looks like a bug. Will check it for the next update.

Workaround:
B4X:
Private MyNull As String = "~null~" 'global variable

Private Sub MapToJson(map As Map) As String
    Return map.As(JSON).ToString.Replace($""${MyNull}""$, "null")
End Sub

Dim Map As Map = CreateMap("test": MyNull)
Log(MapToJson(Map))
 
Upvote 0
Top