Major refactor from djorm-ext-pgjson