Skip to main content

json/
json.rs

1use bel::{Context, Program};
2
3fn main() {
4    // Create a CEL program that returns a JSON object
5    let program = Program::compile("{'foo': true}").unwrap();
6    let value = program.execute(&Context::default()).unwrap();
7
8    // Convert the return type to JSON and cast to object
9    let json = value.json().unwrap();
10    let object = json.as_object().unwrap();
11    assert_eq!(Some(&serde_json::Value::Bool(true)), object.get("foo"));
12}