From 89ef4c07025169cececca5283c1a6fa4d1980fdd Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 28 Feb 2025 17:49:09 +0100 Subject: [PATCH] Expr: convert Json bool to 1/0 numerical type. --- Makefile | 2 +- expr.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index de73b3abf..ed069801d 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ all: vset.so .c.xo: $(CC) -I. $(CFLAGS) $(SHOBJ_CFLAGS) -fPIC -c $< -o $@ -vset.xo: redismodule.h +vset.xo: redismodule.h expr.c vset.so: vset.xo hnsw.xo cJSON.xo $(CC) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc diff --git a/expr.c b/expr.c index cc77ba94e..325edb900 100644 --- a/expr.c +++ b/expr.c @@ -715,6 +715,10 @@ exprtoken *exprJsonToToken(cJSON *js) { obj->str.start = obj->str.heapstr; obj->str.len = strlen(obj->str.heapstr); return obj; + } else if (cJSON_IsBool(js)) { + exprtoken *obj = exprNewToken(EXPR_TOKEN_NUM); + obj->num = cJSON_IsTrue(js); + return obj; } else if (cJSON_IsArray(js)) { // First, scan the array to ensure it only // contains strings and numbers. Otherwise the