diff options
author | drh <> | 2025-05-24 20:20:20 +0000 |
---|---|---|
committer | drh <> | 2025-05-24 20:20:20 +0000 |
commit | a01b7adb1345b57063c5937fb98ffe6fb89657d9 (patch) | |
tree | f7f2b53c2da84364915f26cf243732d2d5b5a347 /src/json.c | |
parent | c5031b578b027a680524496617f638d4f8a3f54e (diff) | |
download | sqlite-a01b7adb1345b57063c5937fb98ffe6fb89657d9.tar.gz sqlite-a01b7adb1345b57063c5937fb98ffe6fb89657d9.zip |
Change json_group_object() so that it ignores entries where the label
is NULL. [forum:/forumpost/e5bd251fb5|Forum post e5bd251fb5].
FossilOrigin-Name: 28215d131cd970a2756338579fb6b6091ab155be8f419505cae8ac918956165c
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/json.c b/src/json.c index ee4cf1cbc..4ae17a5a4 100644 --- a/src/json.c +++ b/src/json.c @@ -4850,18 +4850,20 @@ static void jsonObjectStep( UNUSED_PARAMETER(argc); pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); if( pStr ){ + z = (const char*)sqlite3_value_text(argv[0]); + n = sqlite3Strlen30(z); if( pStr->zBuf==0 ){ jsonStringInit(pStr, ctx); jsonAppendChar(pStr, '{'); - }else if( pStr->nUsed>1 ){ + }else if( pStr->nUsed>1 && z!=0 ){ jsonAppendChar(pStr, ','); } pStr->pCtx = ctx; - z = (const char*)sqlite3_value_text(argv[0]); - n = sqlite3Strlen30(z); - jsonAppendString(pStr, z, n); - jsonAppendChar(pStr, ':'); - jsonAppendSqlValue(pStr, argv[1]); + if( z!=0 ){ + jsonAppendString(pStr, z, n); + jsonAppendChar(pStr, ':'); + jsonAppendSqlValue(pStr, argv[1]); + } } } static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){ |