util.as_json() for consistent JSON dumping