difftreelog
fix yaml stream handling difference
in: master
1 file changed
crates/jrsonnet-stdlib/src/parse.rsdiffbeforeafterboth1use jrsonnet_evaluator::{IStr, Result, Val, function::builtin, runtime_error};23#[builtin]4pub fn builtin_parse_json(str: IStr) -> Result<Val> {5 let value: Val =6 serde_json::from_str(&str).map_err(|e| runtime_error!("failed to parse json: {e}"))?;7 Ok(value)8}910#[builtin]11pub fn builtin_parse_yaml(str: IStr) -> Result<Val> {12 let out = serde_saphyr::from_multiple_with_options::<Val>(13 &str,14 serde_saphyr::Options {15 // Golang/C++ compat16 legacy_octal_numbers: true,17 // Disable budget limits - we trust the YAML input18 budget: None,19 ..Default::default()20 },21 )22 .map_err(|e| runtime_error!("failed to parse yaml: {e}"))?;23 Ok(if out.is_empty() {24 Val::Null25 } else if out.len() == 1 {26 out.into_iter().next().unwrap()27 } else {28 Val::Arr(out.into())29 })30}