In a previous blog post we saw how to do case insensitive retrieval from maps.
A better solution for this if there are many key lookups is to transform the input by lower casing all the keys just after decoding. The solution from the blog post would iterate over each {key, value}
pair till it found the desired key.
However a proper map lookup doesn’t iterate over the keys but uses a hashing algorithm to get to the key’s location in constant time regardless of the size of the map.
Anyway, Here is the solution to transform each key for input JSON. Hope you find it useful :)
1 | defmodule KeyTransformer do |
I am currently working on LiveForm which makes
setting up contact forms on your website a breeze.