mirror of
https://github.com/mailscope/kumomta.git
synced 2026-08-25 21:58:18 +00:00
mod-serde: sort pretty-printed json object keys
This makes things a bit easier for human consumption, especially for the `resolve-shaping-domain` utility.
This commit is contained in:
@@ -81,6 +81,12 @@ fn json_encode(lua: &Lua, value: LuaValue) -> mlua::Result<String> {
|
||||
|
||||
fn json_encode_pretty(lua: &Lua, value: LuaValue) -> mlua::Result<String> {
|
||||
let value = materialize_to_lua_value(lua, value)?;
|
||||
// This additional conversion to a json value causes any object types
|
||||
// to become backed by a BTreeMap rather than lua's randomly ordered
|
||||
// table type, so that the pretty print will show the keys in sorted order.
|
||||
// We only do that for pretty printing because we don't usually want
|
||||
// to bother with that additional overhead
|
||||
let value = serde_json::to_value(&value).map_err(any_err)?;
|
||||
serde_json::to_string_pretty(&value).map_err(any_err)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
reported earlier and/or more frequently than in prior versions, but should
|
||||
result in less of an overall bottleneck in the triggering scenario.
|
||||
|
||||
* [kumo.serde.json_encode_pretty](../reference/kumo.serde/json_encode_pretty.md)
|
||||
now outputs keys of json objects in sorted order. This means that utilities
|
||||
such as `resolve-shaping-domain` will now output keys in sorted order as well.
|
||||
|
||||
## Fixes
|
||||
|
||||
* sources helper didn't allow creating empty egress pools
|
||||
|
||||
Reference in New Issue
Block a user