JSONUtilities
JSONUtilities copied to clipboard
Ability to escape dots that should not be handled as keypaths
If a key is "some.key" this treated as a keypath made of "some" and "key". Even though it's rare that an API would provide keys with dots it would be useful to add the ability to escape the dots.
For example:
let name: String = try jsonDictionary.json(atKeyPath: "some\\.key")
Should the escape be just a single \
to be consistent with other DSLs? In your example it looks like you're escaping the escape character, so when evaluated it becomes some\.key
That sounds like a very sensible approach to me. We probably need to escape the slash as well. I'm guessing something like some\\\.key
for a JSON key the would be some\.key
.