aboutsummaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authordrh <>2023-10-05 18:09:12 +0000
committerdrh <>2023-10-05 18:09:12 +0000
commit5b6cfb79068f20f4df34322139ef7c0b9d58ea2c (patch)
tree19d413157276d60ed95af7f98240a0048ada3bec /src/json.c
parent14fce24a9bacf6e872154a2a679ff95acb10a7a8 (diff)
downloadsqlite-5b6cfb79068f20f4df34322139ef7c0b9d58ea2c.tar.gz
sqlite-5b6cfb79068f20f4df34322139ef7c0b9d58ea2c.zip
Change the json_valid(X) routine to return true whenever X is a blob that
could plausibly be a valid JSONB. FossilOrigin-Name: 425f0b85a6f8ad0604c4a5faa18efb90436fedb1fe2612a559147c62cff8b7e7
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/json.c b/src/json.c
index ba701ba68..3c179ac16 100644
--- a/src/json.c
+++ b/src/json.c
@@ -4812,8 +4812,14 @@ static void jsonTypeFunc(
/*
** json_valid(JSON)
**
-** Return 1 if JSON is a well-formed canonical JSON string according
-** to RFC-7159. Return 0 otherwise.
+** Return 1 if the argument is one of:
+**
+** * A well-formed canonical JSON string according to RFC-8259
+** (without JSON5 enhancements), or
+**
+** * A BLOB that plausibly could be a JSONB value.
+**
+** Return 0 otherwise.
*/
static void jsonValidFunc(
sqlite3_context *ctx,
@@ -4829,6 +4835,10 @@ static void jsonValidFunc(
#endif
return;
}
+ if( jsonFuncArgMightBeBinary(argv[0]) ){
+ sqlite3_result_int(ctx, 1);
+ return;
+ }
p = jsonParseCached(ctx, argv[0], 0, 0);
if( p==0 || p->oom ){
sqlite3_result_error_nomem(ctx);