Adds as_json method