red30 Well-Known Member Licensed User Longtime User Feb 8, 2023 #1 B4X: Copy 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: Feb 8, 2023
B4X: Copy 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 ...
Erel B4X founder Staff member Licensed User Longtime User Feb 8, 2023 #2 It looks like a bug. Will check it for the next update. Workaround: Code: Copy 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
It looks like a bug. Will check it for the next update. Workaround: Code: Copy 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))