MCPcopy Create free account
hub / github.com/cel-rust/cel-rust / main

Function main

example/src/json.rs:3–12  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1use cel::{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}

Callers

nothing calls this directly

Calls 2

executeMethod · 0.80
jsonMethod · 0.45

Tested by

no test coverage detected