Functional REST -> DB -> JSON -> Object Mapping algorithm