Closed ghost closed 5 years ago
Is this still the problem? Did you try SetRaw method?
Doesn't seem like it. For keys where I have no control over their format I use
func escape(str string) string {
return strings.Replace(`.`, `\.`, str, -1)
}
I haven't done proper testing but I think this is no longer an issue.
Hi, I am storing changes made to documents in key-value format(https://github.com/tidwall/gjson/issues/103) and I have an issue with escaped keys.
If I call
set foo.bar.baz 1
I will store this change as{"foo.bar.baz": 1}
but I am not able to store changes if I callset foo\.bar\.baz 1
which should result into{"foo\.bar\.baz": 1}
because keys do not have option to set raw value, like values do.So far the only solutions that come to mind are:
map[string]interface{}
for the changes which I would have to convert to json later on, avoiding sjson for changes completely(currently the least intrusive solution)... but I would prefer avoiding workarounds with something like
SetOptions()