MCPcopy Create free account
hub / github.com/block/buzz / json_value_to_eval

Function json_value_to_eval

crates/buzz-workflow/src/executor.rs:332–349  ·  view source on GitHub ↗

Convert a `serde_json::Value` to an `evalexpr::Value`.

(v: &JsonValue)

Source from the content-addressed store, hash-verified

330
331/// Convert a `serde_json::Value` to an `evalexpr::Value`.
332fn json_value_to_eval(v: &JsonValue) -> evalexpr::Value {
333 use evalexpr::Value as EV;
334 match v {
335 JsonValue::String(s) => EV::String(s.clone()),
336 JsonValue::Bool(b) => EV::Boolean(*b),
337 JsonValue::Number(n) => {
338 if let Some(i) = n.as_i64() {
339 EV::Int(i)
340 } else if let Some(f) = n.as_f64() {
341 EV::Float(f)
342 } else {
343 EV::String(n.to_string())
344 }
345 }
346 JsonValue::Null => EV::Empty,
347 other => EV::String(other.to_string()),
348 }
349}
350
351/// Maximum wall-clock time allowed for a single `evalexpr` evaluation.
352///

Callers 1

build_eval_contextFunction · 0.85

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected