-
Notifications
You must be signed in to change notification settings - Fork 39
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
Word convention for JSON #47
Comments
What are you planning on controlling with such a flag? You can already control which fields to use by using struct tags or naming your input variables to service functions. As for the fields in the JSON RPC response itself, the names has to follow the JSON RPC spec. |
@smyrman , the JSONRPC spec does not specify json word convention. lowerCamelCase variant:
snake_case variant:
The both are possible by the spec. The both are usable. But only one works now. |
Sorry for being unclear, I was referring to the reserved words ( But to achive what you want, you should be able to do the following? func (srv *Service) Some_method(some_param, some_other_param int) (*int, *zenrpc.Error) {
} Not saying this is nice in Go, but you could solve that by letting the service method become a thin wrapper for your actual (private) method with propper naming. And for nested data-structures, rely on json-tags. |
Thank you so much for such tricks, @smyrman. As you mention, it is technically possible to solve the problem using current state of zenrpc, but I believe we can improve zenrpc and make it more convenient and less tricky. |
This feature is available in my old pr and can be easily copied to some fork. |
Sometimes it matters which word convention do you use.
For example, in some projects it is a rule to use only snake_case in json properties.
Now we do not have any options for the problem. I suggest to add some flag for word convention.
The text was updated successfully, but these errors were encountered: