fix JSON array/object parser regression in JParser::parse_value
This commit is contained in:
+1
-1
@@ -225,7 +225,7 @@ bool parse_nonstream_response(std::string_view body, Message &out, Usage &usage)
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
/* llm.cpp — HTTP client (libcurl), headers, backoff, dispatch. */
|
/* llm.cpp — HTTP client (libcurl), headers, backoff, dispatch. */
|
||||||
/* -------------------------------------------------------------- */
|
/* ------------------------------------------------------------------ */
|
||||||
int http_get(Cfg &cfg, std::string_view url, std::string &body, long &code,
|
int http_get(Cfg &cfg, std::string_view url, std::string &body, long &code,
|
||||||
std::string &errmsg);
|
std::string &errmsg);
|
||||||
int llm(Cfg &cfg, Messages &msgs, bool use_tools, Message &out, Usage &usage,
|
int llm(Cfg &cfg, Messages &msgs, bool use_tools, Message &out, Usage &usage,
|
||||||
|
|||||||
@@ -401,6 +401,30 @@ struct JParser {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (c == '[') {
|
if (c == '[') {
|
||||||
|
pos++;
|
||||||
|
skip_ws();
|
||||||
|
out = Json::array();
|
||||||
|
if (pos < src.size() && src[pos] == ']') {
|
||||||
|
pos++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
Json elem;
|
||||||
|
if (!parse_value(elem, depth + 1)) return false;
|
||||||
|
out.aval.push_back(std::move(elem));
|
||||||
|
skip_ws();
|
||||||
|
if (pos < src.size() && src[pos] == ',') {
|
||||||
|
pos++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (pos < src.size() && src[pos] == ']') {
|
||||||
|
pos++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c == '{') {
|
||||||
pos++;
|
pos++;
|
||||||
skip_ws();
|
skip_ws();
|
||||||
out = Json::object();
|
out = Json::object();
|
||||||
|
|||||||
Reference in New Issue
Block a user