Little refactoring for json module