jinja: support json sort_keys=true (#32366)

This commit is contained in:
Xuan-Son Nguyen authored and GitHub committed 2026-11-16 12:28:19 +01:00
1 parent 95db855bce
commit e1925b3695
3 files changed
+27 -15

No files matched your search

+6
View File
@@ -1132,6 +1132,12 @@ static void test_filters(testing & t) {
"{\"a\": 1, \"b\": 2}"
);
test_template(t, "tojson sort_keys=true nested with separators",
"{{ data|tojson(sort_keys=true, separators=(',',':')) }}",
{{"data", {{"name", "f"}, {"args", {{"z", 1}, {"a", json::array({json{{"y", 2}, {"b", 3}}})}}}}}},
"{\"args\":{\"a\":[{\"b\":3,\"y\":2}],\"z\":1},\"name\":\"f\"}"
);
test_template(t, "tojson",
"{{ data|tojson }}",
{{"data", {{"a", 1}, {"b", json::array({1, 2})}}}},