code refactoring for json management