I have looked all over to find a way to disable the "escaping" of the slash "/" in a JSON string created by the JSONGenerator but I am at a loss at this point without a solution. For example in this very simple code fragment:
B4X:
Dim Map1 As Map
Map1.Initialize
Map1.Put("AdminFolder","root/users/admin")
Dim JSONGenerator As JSONGenerator
JSONGenerator.Initialize(Map1)
Log(JSONGenerator.ToPrettyString(2))
The Log produces:
{ "AdminFolder": "root\/users\/admin" }
What I would like to get is:
{ "AdminFolder": "root/users/admin" }
Any suggestions would be greatly appreciated.
Thanks!
you could do it by hand (like you did), but it might not be readable on the other end. escaping certain characters is part of the json spec. it's like asking, when i translate something into italian, why do the words come out in italian? they're supposed to.
Having said that by @drgottjr, you may want to reconsider the structure of the json object, in case you are in control of the receiving side, with something like:
Thanks for the feedback. I do have a work-around, but I thought there may be a more direct way of disabling the "escaping" part of the JSON spec. This works:
B4X:
Dim Map1 As Map
Map1.Initialize
Dim s As String
Map1.Put("AdminFolder","root/users/admin")
Dim JSONGenerator As JSONGenerator
JSONGenerator.Initialize(Map1)
s = JSONGenerator.ToString
s=s.Replace("\/","/")
Log(s)