Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

llama: parse JSON schema using nlohmann::ordered_json to maintain ordering (#8071)

Pascal Patryc21685052311
diff --git a/llama/sampling_ext.cpp b/llama/sampling_ext.cpp
index 926b68a1e..030864a13 100644
--- a/llama/sampling_ext.cpp
+++ b/llama/sampling_ext.cpp
@@ -49,7 +49,7 @@ int schema_to_grammar(const char *json_schema, char *grammar, size_t max_len)
{
try
{
- nlohmann::json schema = nlohmann::json::parse(json_schema);
+ nlohmann::ordered_json schema = nlohmann::ordered_json::parse(json_schema);
std::string grammar_str = json_schema_to_grammar(schema);
size_t len = grammar_str.length();
if (len >= max_len)