janl / erl-jsonpointer

JSON Pointer implementation for Erlang
http://tools.ietf.org/html/draft-pbryan-zyp-json-pointer-00
MIT License
13 stars 3 forks source link

Percent encoding should be separated #2

Open zuiderkwast opened 10 years ago

zuiderkwast commented 10 years ago

When the JSON Pointer is represented as a string, it should not be percent encoded. See section 5 "JSON String Representation" [1] in the RFC.

When the JSON Pointer is included in an URL, as in section 6 "URI Fragment Identifier Representation" [2] in the RFC, it should be percent encoded (just like any other string when it is inserted into an URI) and a "#" prepended, since it is an URI "fragment". This is a separate process and not really part of the JSON Pointer format, since the string representation can be used alone.

I suggest percent encoding be removed from the parse/1. For this, the OTP function http_uri:decode/1 [3] can be used.

[1] http://tools.ietf.org/html/rfc6901#section-5 [2] http://tools.ietf.org/html/rfc6901#section-6 [3] http://erlang.org/doc/man/http_uri.html#decode-1

janl commented 10 years ago

Heya, I believe the current implementation is not up to date with the latest versions of the spec, hence the discrepancies. Patches are very welcome! :)