Skip to main content

parse_expr_value

Function parse_expr_value 

Source
pub fn parse_expr_value(json: &Value) -> ExprValue
Expand description

Parse a JSON value into an ExprValue, extracting all ${...} expressions.

This function recursively converts JSON into ExprValue:

  • Strings containing ${...} become Expr (if entire string) or Interpolated (if mixed)
  • Plain strings become Literal(String)
  • Numbers, bools, null become their Literal equivalents
  • 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(_)));