This is ok, but I have a simpler pattern based on is_a(JSON, type, key) that would make the code more readable.  See the attrib.erl file.