I know I can delete the whole file with "File.Delete(xui.defaultfolder, DataFile)". But how do I delete just part of this json file? I'm guessing there is some way to delete using the key of the value I want to delete?
Sub FileRemove(part As String)
Dim xui As XUI, Data As Map
Public const DataFile As String = "data.dat"
Data.Initialize
Dim ser As B4XSerializator
Data = ser.ConvertBytesToObject(File.ReadBytes(xui.DefaultFolder, DataFile))
Log(Data)
Data.Remove(part)
Log(Data)
File.WriteBytes(xui.DefaultFolder, DataFile, ser.ConvertObjectToBytes(Data))
End Sub
Please let me know if you would change/improve. Thanks!
i would completely go another route.
I would use jsonparser to get a map/list out from the json, then i would remove unwanted keys from the map/list and generate a new json using jsongenerator.
i would completely go another route.
I would use jsonparser to get a map/list out from the json, then i would remove unwanted keys from the map/list and generate a new json using jsongenerator.
Thanks, DonManfred! I incorrectly called the file a json file. It is a Data Map file (generated from a Preferences Dialog created with FormsBuilder built with a json file). Given this corrected description I would greatly appreciate any comment you might have on my code.
Thanks!