clarkmcc / cel-rust

Common Expression Language interpreter written in Rust
https://crates.io/crates/cel-interpreter
MIT License
362 stars 18 forks source link

Convert CEL values to JSON #77

Closed clarkmcc closed 1 month ago

clarkmcc commented 1 month ago

This PR adds support for converting CEL values to JSON values.

  1. Enable the JSON feature
    cel-interpreter = { ..., features = ["json"] }
  2. Use method on CEL values to convert to JSON
    
    let value = program.execute(&Context::default()).unwrap();
    let json = value.json().unwrap();
clarkmcc commented 1 month ago

CC'ing @jplock @alexsnaps since we've talked around this feature/issue in the past (see #68).

jplock commented 1 month ago

Tested the latest changes in this branch, works great. Thank you for the fix 👍