Use Json.reads and Json.writes to refactor codes