Allow to_json() to deal with a list of objects