git.delta.rocks / jrsonnet / refs/commits / 2d3e9127fca2

difftreelog

Merge remote-tracking branch 'origin/master' into gcmodule

Yaroslav Bolyukin2022-01-04parents: #fa16ccf #e1fb5e1.patch.diff
in: master

7 files changed

modifiedcrates/jrsonnet-evaluator/src/builtin/manifest.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/builtin/manifest.rs
1use crate::error::Error::*;2use crate::error::Result;3use crate::push_description_frame;4use crate::{throw, Val};56#[derive(PartialEq, Clone, Copy)]7pub enum ManifestType {8	// Applied in manifestification9	Manifest,10	/// Used for std.manifestJson11	/// Empty array/objects extends to "[\n\n]" instead of "[ ]" as in manifest12	Std,13	/// No line breaks, used in `obj+''`14	ToString,15	/// Minified json16	Minify,17}1819pub struct ManifestJsonOptions<'s> {20	pub padding: &'s str,21	pub mtype: ManifestType,22}2324pub fn manifest_json_ex(val: &Val, options: &ManifestJsonOptions<'_>) -> Result<String> {25	let mut out = String::new();26	manifest_json_ex_buf(val, &mut out, &mut String::new(), options)?;27	Ok(out)28}29fn manifest_json_ex_buf(30	val: &Val,31	buf: &mut String,32	cur_padding: &mut String,33	options: &ManifestJsonOptions<'_>,34) -> Result<()> {35	use std::fmt::Write;36	let mtype = options.mtype;37	match val {38		Val::Bool(v) => {39			if *v {40				buf.push_str("true");41			} else {42				buf.push_str("false");43			}44		}45		Val::Null => buf.push_str("null"),46		Val::Str(s) => escape_string_json_buf(s, buf),47		Val::Num(n) => write!(buf, "{}", n).unwrap(),48		Val::Arr(items) => {49			buf.push('[');50			if !items.is_empty() {51				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {52					buf.push('\n');53				}5455				let old_len = cur_padding.len();56				cur_padding.push_str(options.padding);57				for (i, item) in items.iter().enumerate() {58					if i != 0 {59						buf.push(',');60						if mtype == ManifestType::ToString {61							buf.push(' ');62						} else if mtype != ManifestType::Minify {63							buf.push('\n');64						}65					}66					buf.push_str(cur_padding);67					manifest_json_ex_buf(&item?, buf, cur_padding, options)?;68				}69				cur_padding.truncate(old_len);7071				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {72					buf.push('\n');73					buf.push_str(cur_padding);74				}75			} else if mtype == ManifestType::Std {76				buf.push_str("\n\n");77				buf.push_str(cur_padding);78			} else if mtype == ManifestType::ToString || mtype == ManifestType::Manifest {79				buf.push(' ');80			}81			buf.push(']');82		}83		Val::Obj(obj) => {84			obj.run_assertions()?;85			buf.push('{');86			let fields = obj.fields();87			if !fields.is_empty() {88				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {89					buf.push('\n');90				}9192				let old_len = cur_padding.len();93				cur_padding.push_str(options.padding);94				for (i, field) in fields.into_iter().enumerate() {95					if i != 0 {96						buf.push(',');97						if mtype == ManifestType::ToString {98							buf.push(' ');99						} else if mtype != ManifestType::Minify {100							buf.push('\n');101						}102					}103					buf.push_str(cur_padding);104					escape_string_json_buf(&field, buf);105					buf.push_str(": ");106					push_description_frame(107						|| format!("field <{}> manifestification", field.clone()),108						|| {109							let value = obj.get(field.clone())?.unwrap();110							manifest_json_ex_buf(&value, buf, cur_padding, options)?;111							Ok(Val::Null)112						},113					)?;114				}115				cur_padding.truncate(old_len);116117				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {118					buf.push('\n');119					buf.push_str(cur_padding);120				}121			} else if mtype == ManifestType::Std {122				buf.push_str("\n\n");123				buf.push_str(cur_padding);124			} else if mtype == ManifestType::ToString || mtype == ManifestType::Manifest {125				buf.push(' ');126			}127			buf.push('}');128		}129		Val::Func(_) => throw!(RuntimeError("tried to manifest function".into())),130	};131	Ok(())132}133134pub fn escape_string_json(s: &str) -> String {135	let mut buf = String::new();136	escape_string_json_buf(s, &mut buf);137	buf138}139140fn escape_string_json_buf(s: &str, buf: &mut String) {141	use std::fmt::Write;142	buf.push('"');143	for c in s.chars() {144		match c {145			'"' => buf.push_str("\\\""),146			'\\' => buf.push_str("\\\\"),147			'\u{0008}' => buf.push_str("\\b"),148			'\u{000c}' => buf.push_str("\\f"),149			'\n' => buf.push_str("\\n"),150			'\r' => buf.push_str("\\r"),151			'\t' => buf.push_str("\\t"),152			c if c < 32 as char || (c >= 127 as char && c <= 159 as char) => {153				write!(buf, "\\u{:04x}", c as u32).unwrap()154			}155			c => buf.push(c),156		}157	}158	buf.push('"');159}160161pub struct ManifestYamlOptions<'s> {162	/// Padding before fields, i.e163	/// ```yaml164	/// a:165	///   b:166	/// ## <- this167	/// ```168	pub padding: &'s str,169	/// Padding before array elements in objects170	/// ```yaml171	/// a:172	///   - 1173	/// ## <- this174	/// ```175	pub arr_element_padding: &'s str,176	/// Should yaml keys appear unescaped, when possible177	/// ```yaml178	/// "safe_key": 1179	/// # vs180	/// safe_key: 1181	/// ```182	pub quote_keys: bool,183}184185/// From https://github.com/chyh1990/yaml-rust/blob/da52a68615f2ecdd6b7e4567019f280c433c1521/src/emitter.rs#L289186/// With added date check187fn yaml_needs_quotes(string: &str) -> bool {188	fn need_quotes_spaces(string: &str) -> bool {189		string.starts_with(' ') || string.ends_with(' ')190	}191192	string.is_empty()193		|| need_quotes_spaces(string)194		|| string.starts_with(|c| matches!(c, '&' | '*' | '?' | '|' | '-' | '<' | '>' | '=' | '!' | '%' | '@'))195		|| string.contains(|c| matches!(c, ':' | '{' | '}' | '[' | ']' | ',' | '#' | '`' | '\"' | '\'' | '\\' | '\0'..='\x06' | '\t' | '\n' | '\r' | '\x0e'..='\x1a' | '\x1c'..='\x1f'))196		|| [197			// http://yaml.org/type/bool.html198			// Note: 'y', 'Y', 'n', 'N', is not quoted deliberately, as in libyaml. PyYAML also parse199			// them as string, not booleans, although it is violating the YAML 1.1 specification.200			// See https://github.com/dtolnay/serde-yaml/pull/83#discussion_r152628088.201			"yes", "Yes", "YES", "no", "No", "NO", "True", "TRUE", "true", "False", "FALSE", "false",202			"on", "On", "ON", "off", "Off", "OFF", // http://yaml.org/type/null.html203			"null", "Null", "NULL", "~",204		].contains(&string)205		|| (string.chars().all(|c| matches!(c, '0'..='9' | '-'))206			&& string.chars().filter(|c| *c == '-').count() == 2)207		|| string.starts_with('.')208		|| string.starts_with("0x")209		|| string.parse::<i64>().is_ok()210		|| string.parse::<f64>().is_ok()211}212213pub fn manifest_yaml_ex(val: &Val, options: &ManifestYamlOptions<'_>) -> Result<String> {214	let mut out = String::new();215	manifest_yaml_ex_buf(val, &mut out, &mut String::new(), options)?;216	Ok(out)217}218fn manifest_yaml_ex_buf(219	val: &Val,220	buf: &mut String,221	cur_padding: &mut String,222	options: &ManifestYamlOptions<'_>,223) -> Result<()> {224	use std::fmt::Write;225	match val {226		Val::Bool(v) => {227			if *v {228				buf.push_str("true")229			} else {230				buf.push_str("false")231			}232		}233		Val::Null => buf.push_str("null"),234		Val::Str(s) => {235			if s.is_empty() {236				buf.push_str("\"\"");237			} else if let Some(s) = s.strip_suffix('\n') {238				buf.push('|');239				for line in s.split('\n') {240					buf.push('\n');241					buf.push_str(options.padding);242					buf.push_str(line);243				}244			} else if !options.quote_keys && !yaml_needs_quotes(s) {245				buf.push_str(s);246			} else {247				escape_string_json_buf(s, buf);248			}249		}250		Val::Num(n) => write!(buf, "{}", *n).unwrap(),251		Val::Arr(a) => {252			if a.is_empty() {253				buf.push_str("[]");254			} else {255				for (i, item) in a.iter().enumerate() {256					if i != 0 {257						buf.push('\n');258						buf.push_str(cur_padding);259					}260					let item = item?;261					buf.push('-');262					match &item {263						Val::Arr(a) if !a.is_empty() => {264							buf.push('\n');265							buf.push_str(cur_padding);266							buf.push_str(options.padding);267						}268						_ => buf.push(' '),269					}270					let extra_padding = match &item {271						Val::Arr(a) => !a.is_empty(),272						Val::Obj(o) => !o.is_empty(),273						_ => false,274					};275					let prev_len = cur_padding.len();276					if extra_padding {277						cur_padding.push_str(options.padding);278					}279					manifest_yaml_ex_buf(&item, buf, cur_padding, options)?;280					cur_padding.truncate(prev_len);281				}282			}283		}284		Val::Obj(o) => {285			if o.is_empty() {286				buf.push_str("{}");287			} else {288				for (i, key) in o.fields().iter().enumerate() {289					if i != 0 {290						buf.push('\n');291						buf.push_str(cur_padding);292					}293					if !options.quote_keys && !yaml_needs_quotes(key) {294						buf.push_str(key);295					} else {296						escape_string_json_buf(key, buf);297					}298					buf.push(':');299					let prev_len = cur_padding.len();300					let item = o.get(key.clone())?.expect("field exists");301					match &item {302						Val::Arr(a) if !a.is_empty() => {303							buf.push('\n');304							buf.push_str(cur_padding);305							buf.push_str(options.arr_element_padding);306							cur_padding.push_str(options.arr_element_padding);307						}308						Val::Obj(o) if !o.is_empty() => {309							buf.push('\n');310							buf.push_str(cur_padding);311							buf.push_str(options.padding);312							cur_padding.push_str(options.padding);313						}314						_ => buf.push(' '),315					}316					manifest_yaml_ex_buf(&item, buf, cur_padding, options)?;317					cur_padding.truncate(prev_len);318				}319			}320		}321		Val::Func(_) => throw!(RuntimeError("tried to manifest function".into())),322	}323	Ok(())324}
after · crates/jrsonnet-evaluator/src/builtin/manifest.rs
1use crate::error::Error::*;2use crate::error::Result;3use crate::push_description_frame;4use crate::{throw, Val};56#[derive(PartialEq, Clone, Copy)]7pub enum ManifestType {8	// Applied in manifestification9	Manifest,10	/// Used for std.manifestJson11	/// Empty array/objects extends to "[\n\n]" instead of "[ ]" as in manifest12	Std,13	/// No line breaks, used in `obj+''`14	ToString,15	/// Minified json16	Minify,17}1819pub struct ManifestJsonOptions<'s> {20	pub padding: &'s str,21	pub mtype: ManifestType,22	pub newline: &'s str,23	pub key_val_sep: &'s str,24}2526pub fn manifest_json_ex(val: &Val, options: &ManifestJsonOptions<'_>) -> Result<String> {27	let mut out = String::new();28	manifest_json_ex_buf(val, &mut out, &mut String::new(), options)?;29	Ok(out)30}31fn manifest_json_ex_buf(32	val: &Val,33	buf: &mut String,34	cur_padding: &mut String,35	options: &ManifestJsonOptions<'_>,36) -> Result<()> {37	use std::fmt::Write;38	let mtype = options.mtype;39	match val {40		Val::Bool(v) => {41			if *v {42				buf.push_str("true");43			} else {44				buf.push_str("false");45			}46		}47		Val::Null => buf.push_str("null"),48		Val::Str(s) => escape_string_json_buf(s, buf),49		Val::Num(n) => write!(buf, "{}", n).unwrap(),50		Val::Arr(items) => {51			buf.push('[');52			if !items.is_empty() {53				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {54					buf.push_str(options.newline);55				}5657				let old_len = cur_padding.len();58				cur_padding.push_str(options.padding);59				for (i, item) in items.iter().enumerate() {60					if i != 0 {61						buf.push(',');62						if mtype == ManifestType::ToString {63							buf.push(' ');64						} else if mtype != ManifestType::Minify {65							buf.push_str(options.newline);66						}67					}68					buf.push_str(cur_padding);69					manifest_json_ex_buf(&item?, buf, cur_padding, options)?;70				}71				cur_padding.truncate(old_len);7273				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {74					buf.push_str(options.newline);75					buf.push_str(cur_padding);76				}77			} else if mtype == ManifestType::Std {78				buf.push_str("\n\n");79				buf.push_str(cur_padding);80			} else if mtype == ManifestType::ToString || mtype == ManifestType::Manifest {81				buf.push(' ');82			}83			buf.push(']');84		}85		Val::Obj(obj) => {86			obj.run_assertions()?;87			buf.push('{');88			let fields = obj.fields();89			if !fields.is_empty() {90				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {91					buf.push_str(options.newline);92				}9394				let old_len = cur_padding.len();95				cur_padding.push_str(options.padding);96				for (i, field) in fields.into_iter().enumerate() {97					if i != 0 {98						buf.push(',');99						if mtype == ManifestType::ToString {100							buf.push(' ');101						} else if mtype != ManifestType::Minify {102							buf.push_str(options.newline);103						}104					}105					buf.push_str(cur_padding);106					escape_string_json_buf(&field, buf);107					buf.push_str(options.key_val_sep);108					push_description_frame(109						|| format!("field <{}> manifestification", field.clone()),110						|| {111							let value = obj.get(field.clone())?.unwrap();112							manifest_json_ex_buf(&value, buf, cur_padding, options)?;113							Ok(Val::Null)114						},115					)?;116				}117				cur_padding.truncate(old_len);118119				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {120					buf.push_str(options.newline);121					buf.push_str(cur_padding);122				}123			} else if mtype == ManifestType::Std {124				buf.push_str("\n\n");125				buf.push_str(cur_padding);126			} else if mtype == ManifestType::ToString || mtype == ManifestType::Manifest {127				buf.push(' ');128			}129			buf.push('}');130		}131		Val::Func(_) => throw!(RuntimeError("tried to manifest function".into())),132	};133	Ok(())134}135136pub fn escape_string_json(s: &str) -> String {137	let mut buf = String::new();138	escape_string_json_buf(s, &mut buf);139	buf140}141142fn escape_string_json_buf(s: &str, buf: &mut String) {143	use std::fmt::Write;144	buf.push('"');145	for c in s.chars() {146		match c {147			'"' => buf.push_str("\\\""),148			'\\' => buf.push_str("\\\\"),149			'\u{0008}' => buf.push_str("\\b"),150			'\u{000c}' => buf.push_str("\\f"),151			'\n' => buf.push_str("\\n"),152			'\r' => buf.push_str("\\r"),153			'\t' => buf.push_str("\\t"),154			c if c < 32 as char || (c >= 127 as char && c <= 159 as char) => {155				write!(buf, "\\u{:04x}", c as u32).unwrap()156			}157			c => buf.push(c),158		}159	}160	buf.push('"');161}162163pub struct ManifestYamlOptions<'s> {164	/// Padding before fields, i.e165	/// ```yaml166	/// a:167	///   b:168	/// ## <- this169	/// ```170	pub padding: &'s str,171	/// Padding before array elements in objects172	/// ```yaml173	/// a:174	///   - 1175	/// ## <- this176	/// ```177	pub arr_element_padding: &'s str,178	/// Should yaml keys appear unescaped, when possible179	/// ```yaml180	/// "safe_key": 1181	/// # vs182	/// safe_key: 1183	/// ```184	pub quote_keys: bool,185}186187/// From https://github.com/chyh1990/yaml-rust/blob/da52a68615f2ecdd6b7e4567019f280c433c1521/src/emitter.rs#L289188/// With added date check189fn yaml_needs_quotes(string: &str) -> bool {190	fn need_quotes_spaces(string: &str) -> bool {191		string.starts_with(' ') || string.ends_with(' ')192	}193194	string.is_empty()195		|| need_quotes_spaces(string)196		|| string.starts_with(|c| matches!(c, '&' | '*' | '?' | '|' | '-' | '<' | '>' | '=' | '!' | '%' | '@'))197		|| string.contains(|c| matches!(c, ':' | '{' | '}' | '[' | ']' | ',' | '#' | '`' | '\"' | '\'' | '\\' | '\0'..='\x06' | '\t' | '\n' | '\r' | '\x0e'..='\x1a' | '\x1c'..='\x1f'))198		|| [199			// http://yaml.org/type/bool.html200			// Note: 'y', 'Y', 'n', 'N', is not quoted deliberately, as in libyaml. PyYAML also parse201			// them as string, not booleans, although it is violating the YAML 1.1 specification.202			// See https://github.com/dtolnay/serde-yaml/pull/83#discussion_r152628088.203			"yes", "Yes", "YES", "no", "No", "NO", "True", "TRUE", "true", "False", "FALSE", "false",204			"on", "On", "ON", "off", "Off", "OFF", // http://yaml.org/type/null.html205			"null", "Null", "NULL", "~",206		].contains(&string)207		|| (string.chars().all(|c| matches!(c, '0'..='9' | '-'))208			&& string.chars().filter(|c| *c == '-').count() == 2)209		|| string.starts_with('.')210		|| string.starts_with("0x")211		|| string.parse::<i64>().is_ok()212		|| string.parse::<f64>().is_ok()213}214215pub fn manifest_yaml_ex(val: &Val, options: &ManifestYamlOptions<'_>) -> Result<String> {216	let mut out = String::new();217	manifest_yaml_ex_buf(val, &mut out, &mut String::new(), options)?;218	Ok(out)219}220fn manifest_yaml_ex_buf(221	val: &Val,222	buf: &mut String,223	cur_padding: &mut String,224	options: &ManifestYamlOptions<'_>,225) -> Result<()> {226	use std::fmt::Write;227	match val {228		Val::Bool(v) => {229			if *v {230				buf.push_str("true")231			} else {232				buf.push_str("false")233			}234		}235		Val::Null => buf.push_str("null"),236		Val::Str(s) => {237			if s.is_empty() {238				buf.push_str("\"\"");239			} else if let Some(s) = s.strip_suffix('\n') {240				buf.push('|');241				for line in s.split('\n') {242					buf.push('\n');243					buf.push_str(options.padding);244					buf.push_str(line);245				}246			} else if !options.quote_keys && !yaml_needs_quotes(s) {247				buf.push_str(s);248			} else {249				escape_string_json_buf(s, buf);250			}251		}252		Val::Num(n) => write!(buf, "{}", *n).unwrap(),253		Val::Arr(a) => {254			if a.is_empty() {255				buf.push_str("[]");256			} else {257				for (i, item) in a.iter().enumerate() {258					if i != 0 {259						buf.push('\n');260						buf.push_str(cur_padding);261					}262					let item = item?;263					buf.push('-');264					match &item {265						Val::Arr(a) if !a.is_empty() => {266							buf.push('\n');267							buf.push_str(cur_padding);268							buf.push_str(options.padding);269						}270						_ => buf.push(' '),271					}272					let extra_padding = match &item {273						Val::Arr(a) => !a.is_empty(),274						Val::Obj(o) => !o.is_empty(),275						_ => false,276					};277					let prev_len = cur_padding.len();278					if extra_padding {279						cur_padding.push_str(options.padding);280					}281					manifest_yaml_ex_buf(&item, buf, cur_padding, options)?;282					cur_padding.truncate(prev_len);283				}284			}285		}286		Val::Obj(o) => {287			if o.is_empty() {288				buf.push_str("{}");289			} else {290				for (i, key) in o.fields().iter().enumerate() {291					if i != 0 {292						buf.push('\n');293						buf.push_str(cur_padding);294					}295					if !options.quote_keys && !yaml_needs_quotes(key) {296						buf.push_str(key);297					} else {298						escape_string_json_buf(key, buf);299					}300					buf.push(':');301					let prev_len = cur_padding.len();302					let item = o.get(key.clone())?.expect("field exists");303					match &item {304						Val::Arr(a) if !a.is_empty() => {305							buf.push('\n');306							buf.push_str(cur_padding);307							buf.push_str(options.arr_element_padding);308							cur_padding.push_str(options.arr_element_padding);309						}310						Val::Obj(o) if !o.is_empty() => {311							buf.push('\n');312							buf.push_str(cur_padding);313							buf.push_str(options.padding);314							cur_padding.push_str(options.padding);315						}316						_ => buf.push(' '),317					}318					manifest_yaml_ex_buf(&item, buf, cur_padding, options)?;319					cur_padding.truncate(prev_len);320				}321			}322		}323		Val::Func(_) => throw!(RuntimeError("tried to manifest function".into())),324	}325	Ok(())326}
modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/mod.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/mod.rs
@@ -1,6 +1,5 @@
 use crate::function::StaticBuiltin;
-use crate::typed::{Any, Null, PositiveF64, VecVal, M1};
-use crate::{self as jrsonnet_evaluator, Either, ObjValue};
+use crate::typed::{Any, PositiveF64, VecVal, M1};
 use crate::{
 	builtin::manifest::{manifest_yaml_ex, ManifestYamlOptions},
 	equals,
@@ -10,6 +9,7 @@
 	typed::{Either2, Either4},
 	with_state, ArrValue, Context, FuncVal, IndexableVal, Val,
 };
+use crate::{Either, ObjValue};
 use format::{format_arr, format_obj};
 use gcmodule::Cc;
 use jrsonnet_interner::IStr;
@@ -145,7 +145,7 @@
 fn builtin_length(x: Either![IStr, VecVal, ObjValue, Cc<FuncVal>]) -> Result<usize> {
 	use Either4::*;
 	Ok(match x {
-		A(x) => x.len(),
+		A(x) => x.chars().count(),
 		B(x) => x.0.len(),
 		C(x) => x
 			.fields_visibility()
@@ -566,12 +566,21 @@
 }
 
 #[jrsonnet_macros::builtin]
-fn builtin_manifest_json_ex(value: Any, indent: IStr) -> Result<String> {
+fn builtin_manifest_json_ex(
+	value: Any,
+	indent: IStr,
+	newline: Option<IStr>,
+	key_val_sep: Option<IStr>,
+) -> Result<String> {
+	let newline = newline.as_deref().unwrap_or("\n");
+	let key_val_sep = key_val_sep.as_deref().unwrap_or(": ");
 	manifest_json_ex(
 		&value.0,
 		&ManifestJsonOptions {
 			padding: &indent,
 			mtype: ManifestType::Std,
+			newline,
+			key_val_sep,
 		},
 	)
 }
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -5,6 +5,9 @@
 	clippy::ptr_arg
 )]
 
+// For jrsonnet-macros
+extern crate self as jrsonnet_evaluator;
+
 mod builtin;
 mod ctx;
 mod dynamic;
@@ -976,6 +979,14 @@
 	}
 
 	#[test]
+	fn json_minified() {
+		assert_json!(
+			r#"std.manifestJsonMinified({a:3, b:4, c:6})"#,
+			r#""{\"a\":3,\"b\":4,\"c\":6}""#
+		);
+	}
+
+	#[test]
 	fn parse_json() {
 		assert_json!(
 			r#"std.parseJson('{"a": -1,"b": 1,"c": 3.141,"d": []}')"#,
modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/typed/conversions.rs
+++ b/crates/jrsonnet-evaluator/src/typed/conversions.rs
@@ -19,7 +19,7 @@
 	($($ty:ty)*) => {$(
 		impl Typed for $ty {
 			const TYPE: &'static ComplexValType =
-				&ComplexValType::BoundedNumber(Some(<$ty>::MIN as f64), Some(<$ty>::MAX as f64));
+				&ComplexValType::BoundedNumber(Some(Self::MIN as f64), Some(Self::MAX as f64));
 		}
 		impl TryFrom<Val> for $ty {
 			type Error = LocError;
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -400,6 +400,8 @@
 				&ManifestJsonOptions {
 					padding: "",
 					mtype: ManifestType::ToString,
+					newline: "\n",
+					key_val_sep: ": ",
 				},
 			)?
 			.into(),
@@ -484,6 +486,8 @@
 				} else {
 					ManifestType::Manifest
 				},
+				newline: "\n",
+				key_val_sep: ": ",
 			},
 		)
 		.map(|s| s.into())
@@ -496,6 +500,8 @@
 			&ManifestJsonOptions {
 				padding: &" ".repeat(padding),
 				mtype: ManifestType::Std,
+				newline: "\n",
+				key_val_sep: ": ",
 			},
 		)
 		.map(|s| s.into())
modifiedcrates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-macros/src/lib.rs
+++ b/crates/jrsonnet-macros/src/lib.rs
@@ -105,7 +105,7 @@
 				if let Some(opt_ty) = extract_type_from_option(&t.ty) {
 					quote! {{
 						if let Some(value) = parsed.get(#ident) {
-							Some(jrsonnet_evaluator::push_description_frame(
+							Some(::jrsonnet_evaluator::push_description_frame(
 								|| format!("argument <{}> evaluation", #ident),
 								|| <#opt_ty>::try_from(value.evaluate()?),
 							)?)
@@ -117,7 +117,7 @@
 					quote! {{
 						let value = parsed.get(#ident).unwrap();
 
-						jrsonnet_evaluator::push_description_frame(
+						::jrsonnet_evaluator::push_description_frame(
 							|| format!("argument <{}> evaluation", #ident),
 							|| <#ty>::try_from(value.evaluate()?),
 						)?
@@ -136,7 +136,7 @@
 		#[derive(Clone, Copy, gcmodule::Trace)]
 		#vis struct #name {}
 		const _: () = {
-			use jrsonnet_evaluator::function::{Builtin, StaticBuiltin, BuiltinParam, ArgsLike};
+			use ::jrsonnet_evaluator::function::{Builtin, StaticBuiltin, BuiltinParam, ArgsLike};
 			const PARAMS: &'static [BuiltinParam] = &[
 				#(#params),*
 			];
@@ -156,7 +156,7 @@
 					PARAMS
 				}
 				fn call(&self, context: Context, loc: Option<&ExprLocation>, args: &dyn ArgsLike) -> Result<Val> {
-					let parsed = jrsonnet_evaluator::function::parse_builtin_call(context, &PARAMS, args, false)?;
+					let parsed = ::jrsonnet_evaluator::function::parse_builtin_call(context, &PARAMS, args, false)?;
 
 					let result: #result = #name(#(#args),*);
 					let result = result?;
modifiedcrates/jrsonnet-stdlib/src/std.jsonnetdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/std.jsonnet
+++ b/crates/jrsonnet-stdlib/src/std.jsonnet
@@ -373,6 +373,8 @@
 
   manifestJson(value):: std.manifestJsonEx(value, '    ') tailstrict,
 
+  manifestJsonMinified(value):: std.manifestJsonEx(value, '', '', ':'),
+
   manifestJsonEx:: $intrinsic(manifestJsonEx),
 
   manifestYamlDoc:: $intrinsic(manifestYamlDoc),
@@ -530,6 +532,9 @@
     else
       patch,
 
+  get(o, f, default = null, inc_hidden = true)::
+    if std.objectHasEx(o, f, inc_hidden) then o[f] else default,
+
   objectFields(o)::
     std.objectFieldsEx(o, false),