Workaround for problem with NULL values in JSON + refactoring