anthonator

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: https://hex.pm/packages/accent
Documentation: https://hexdocs.pm/accent/api-reference.html

Most Liked

anthonator

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! :smile:

OvermindDL1

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… ^.^

Where Next?

Popular in Libraries Top

scohen
Lexical Lexical is a next-generation language server for the Elixir programming language. Features Context aware code completion As-you...
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
nikokozak
Hello all, I’ve been working on Svonix - a library for quickly integrating Svelte components into Phoenix views. It’s a much-needed succ...
New
tfwright
After working on it for a couple of months and using it in production for most of that time, today I’ve released LiveAdmin, a LiveView ba...
New
mbuhot
EctoJob A transactional job queue built with Ecto, PostgreSQL and GenStage Available on Hex.pm: ecto_job | Hex Docs: API Reference — ec...
New
zorbash
I created Kitto a framework for dashboards inspired by Dashing. [demo] The distributed characteristics of Elixir and the low memory foo...
New
engineeringdept
I’ve just released the first version of Snap, an Elasticsearch client. It borrows ideas about application structure and process managemen...
New
Qqwy
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New
vic
Expat is a tiny experiment I did for extracting patterns and being able to reuse them (compose and share patterns between elixir librarie...
New

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Sub Categories:

We're in Beta

About us Mission Statement