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
encoding/json: expose more internals #22034
Comments
I don't have an answer for you, but I can imagine that most people will oppose this. Adding more complexity and long-term burden to the exposed API is a factor against exporting any name in One exception would be someone who wants to write an |
Since I didn't expect this to be quick, I made an quick implementation here: https://github.com/MOZGIII/go-jsontag |
By the way: my usecase is to build a description of a struct (that can also include other structs), with the information for each field about it's JSON name (dot-separated for nesting) and type (string/bool/etc). |
@mvdan Just noticed you mention keeping the license. How do I do it right? It what's in my repo ok? |
I agree with @mvdan. There is insufficient reason to expose this API, and it's easy to implement yourself. Implementing it yourself is not relying on encoding/json internals; it's simply handling the documented tag syntax in a way that is useful for you. Closing the issue. |
I checked out git history and found ot that https://github.com/golang/go/blob/master/src/encoding/json/tags.go has never changed significantly since in was introduced. Could we expose this logic as an API so that applications could parse JSON tags more reliably?
I want this because I'm currently implementing a kind of mapper that translates struct from one form to another, and it needs to know how particular fields will be encoded as JSON. I can't seem to filnd a way to programmatically read JSON marshaller configuration from struct field tags without relying on implementation internals.
Problem is, even though JSON tags format is documented, there's no API provided to ease interoperation with it from the other code. Would be great to have it.
The text was updated successfully, but these errors were encountered: