Override #to_json method to convert to hash first