anthonator
Accent - Plug for converting JSON API keys to different cases
Hey everyone,
I published a new package yesterday that allows a client to request the case it prefers to see the keys of a JSON response in. For example, a JavaScript client may prefer a JSON response to be in pascalCase.
The main goal of the project was to provide the client the ability to make the choice of which case they prefer rather than hard coding a snake_case to pascalCase (or whatever) conversion.
By default, a client can send an Accent header to the server with the case they prefer. Out of the box, we support pascal, camel and snake as options. Both the header used and the supported cases can be customized.
Conversion works both ways. A client can request a response be formatted with a specific case and the server can convert an incoming request to a specific case as well.
Would love to hear your thoughts!
Hex: accent | Hex
Documentation: API Reference — accent v1.1.1
Most Liked
anthonator
Thanks for the feedback!
I’m surprised you think that the use-case is very specific. We have a lot of clients for the web services we create that prefer either pascal or camel case. I think most companies use a RESTful API as opposed to GraphQL. Glad to hear your thoughts though!
I didn’t use Elixir’s implementation because they are not Unicode compliant. They only support ASCII. They say so as much in the Macro docs.
Thanks for the documentation suggestion! I’ll definitely do that.
Thanks again! I really appreciate the time you took take a look! ![]()
OvermindDL1
Nah I bet that was them, I’m surprised they are not unicode compliant, that sounds like a pending PR if they would take it, though considering its built for ‘elixir identifiers’, maybe not… ^.^
Popular in Announcing
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








