JSONUtilities icon indicating copy to clipboard operation
JSONUtilities copied to clipboard

Ability to escape dots that should not be handled as keypaths

Open lucianomarisi opened this issue 8 years ago • 2 comments

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")

lucianomarisi avatar Sep 14 '16 09:09 lucianomarisi

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

yonaskolb avatar Apr 28 '17 07:04 yonaskolb

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.

lucianomarisi avatar Apr 28 '17 09:04 lucianomarisi