dfahlander/typeson

JSON Pointer key paths (or at least escaping "." in property names)

Closed this issue · 1 comments

It looks like the key paths ought to handle escaping for "." characters if present in a property name.

If fixing this, however, I thought, why not just move to the standard JSON Pointer instead which reserves "/" for delimiting (and uses the tilde for escaping the slash (~1) and for the tilde escaping itself (~0); the only other difference is that # represents the whole document (instead of the empty string) and #/ must begin all other paths).

(Btw, I pushed an observer API today (currently for encapsulators, not yet revivers), allowing one to get a callback during encapsulation--see the new tests for current usage--the second test may give an even better idea of how this would be useful. If the API is ok, and if we can decide on this "." issue, I'd like to provide one other convenience in supplying the observer callback with a short keypath like "0" in addition to the "someProperty.0" keypath it currently provides.)

Note that my fix escapes in a similar manner to JSON Pointer, but unless you want a major release change, I avoided changing the "." to "/" or requiring "#" or "#/" at the beginning (i.e., we now escape . in property names as ~1 and escape the tilde escape itself as ~0).