Smarter JSON handling -- allow JSON objects to be returned by specifying
as_json().