pub fn parse_expr_value(json: &Value) -> ExprValueExpand description
Parse a JSON value into an ExprValue, extracting all ${...} expressions.
This function recursively converts JSON into ExprValue:
- Strings containing
${...}becomeExpr(if entire string) orInterpolated(if mixed) - Plain strings become
Literal(String) - Numbers, bools, null become their
Literalequivalents - Objects and arrays are recursed into
§Examples
use rite_model::expression::{parse_expr_value, ExprValue, Literal};
// Plain string → Literal
let json = serde_json::json!("hello");
let expr = parse_expr_value(&json);
assert!(matches!(expr, ExprValue::Literal(Literal::String(_))));
// Expression string → Expr
let json = serde_json::json!("${artifact.ksr | sha256}");
let expr = parse_expr_value(&json);
assert!(matches!(expr, ExprValue::Expr(_)));