Adding an as_json() method.