Gooey chewy library to camelize keys in a map
Works when any child is a list, struct, or any other primitive type. Gracefully ignores DateTime structs.
Add caramelize to your list of dependencies in mix.exs:
def deps do
[{:caramelize, "~> 0.1.0"}]
end
Ensure caramelize is started before your application:
def application do
[applications: [:caramelize]]
end
Simply pass any map into the Caramelize.camelize()
function, and it will return a map with all keys converted to camelCase.
awesome_map = %{test_foo: "foo",
test_bar: %CoolStruct{cool_key: "Cool Value"},
test_baz: ["baz", "boz", "box"],
test_boz: %{awesome_lib: "Thanks man!"}
}
awesomer_map = Caramelize.camelize(awesome_map)
Output:
awesomer_map = %{"testFoo" => "foo",
"testBar" => %CoolStruct{"coolKey" => "Cool Value"},
"testBaz" => ["baz", "boz", "box"],
"testBoz" => %{"awesomeLib" => "Thanks man!"}
}
Pull requests welcome! Add tests to the caramelize_test.exs
and ensure all tests are passing before PR submission.