improved api to have options for as_json