New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: encoding/json: add EvalJSONPointer function to support RFC 6901 #42009
Comments
I think the API needs a bit of work. AIUI it takes an arbitrary Go value and returns a Given that, as far as I can see, nothing in the stdlib benefits from this and the implementation also doesn't benefit from coupling with internal stdlib code, I think the best course of action here is to implement this outside the stdlib to experiment with the API and re-consider the benefits of including it once kinks in the API has been shaken out. |
I agree with Axel; implement this outside of the standard library first. https://golang.org/doc/faq#x_in_std |
On a quick search, I found these implementations with different API:
Edit 1: Added one more implementation (jsonptr) |
encoding/json does support a generic JSON representation - map[string]interface{} - but it's not really the most efficient or preferred implementation most of the time. Would jsonpointer have to work on every possible struct that can be marshaled or unmarshaled with the json package? Also, how commonly used is this? Why not keep using one of the choices outside the standard library? |
As the author of package github.com/dolmen-go/jsonptr I don't think there is a need for a JSON Pointer implementation inside the stdlib. An implementation inside the stdlib would not be easier than any external one. The only valid reason for an stdlib implementation would be to reduce fragmentation by directing most users of JSON Pointer towards the use of that implementation. @rsc wrote:
An under-documented feature of my own implementation is that it supports not just trees of |
I've also published a framework for benchmarking Go implementations of JSON Pointer here: |
Based on the discussion above, this seems like a likely decline. |
No change in consensus, so declined. |
RFC 6901 describes the JSON Pointer standard.
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
More advanced query languages like JSONPath and JMESPath is not required in many cases. Also including it as part of the standard library would be an overkill.
Since JSON Pointer is a small standard, the implementation would be easy.
The API could be something like this:
The text was updated successfully, but these errors were encountered: