[][src]Function balena_temen::evaluate_with_engine

pub fn evaluate_with_engine(
    data: Value,
    engine: &Engine,
    context: &mut Context
) -> Result<Value>

Evaluates the whole JSON with custom Engine


  • data - A JSON to evaluate


use balena_temen::{Context, evaluate_with_engine, Engine, EngineBuilder, Value};
use serde_json::json;

let mut context = Context::default();
let engine: Engine = EngineBuilder::default()

let data = json!({
  "evalMePlease": "1 + 2"

assert_eq!(evaluate_with_engine(data, &engine, &mut context).unwrap(), json!(3));

Check the eval function for more examples.