Sat, 13 Dec 2025 13:33:43 +0100
fix that cxJsonCompare() could not compare integers with numbers
| src/json.c | file | annotate | diff | comparison | revisions |
--- a/src/json.c Sat Dec 13 13:24:02 2025 +0100 +++ b/src/json.c Sat Dec 13 13:33:43 2025 +0100 @@ -1446,7 +1446,10 @@ int cxJsonCompare(const CxJsonValue *json, const CxJsonValue *other) { if (json == NULL && other == NULL) return 0; if (json == NULL || other == NULL) return -1; - if (json->type != other->type) return -1; + if (json->type != other->type) { + if (!cxJsonIsNumber(json)) return -1; + if (!cxJsonIsNumber(other)) return -1; + } switch (json->type) { case CX_JSON_NOTHING: return 0; @@ -1462,9 +1465,9 @@ case CX_JSON_STRING: return cx_strcmp(json->string, other->string); case CX_JSON_INTEGER: - return cx_vcmp_int64(json->integer, other->integer); + return cx_vcmp_int64(json->integer, cxJsonAsInteger(other)); case CX_JSON_NUMBER: - return cx_vcmp_double(json->number, other->number); + return cx_vcmp_double(json->number, cxJsonAsDouble(other)); case CX_JSON_LITERAL: return json->literal == other->literal ? 0 : -1; default: