diff options
author | drh <> | 2023-04-28 11:02:01 +0000 |
---|---|---|
committer | drh <> | 2023-04-28 11:02:01 +0000 |
commit | 1170fb52e12c5476ac8cf03216609c6824953982 (patch) | |
tree | e044b9aa8d6f1ba1b6c91222c43678468b41f0c6 /src/json.c | |
parent | ea2529528ef9f195bbf03c980eb254581aae2bcd (diff) | |
download | sqlite-1170fb52e12c5476ac8cf03216609c6824953982.tar.gz sqlite-1170fb52e12c5476ac8cf03216609c6824953982.zip |
Fix json_tree() so that it is able to deal with the JNODE_RAW labels of
a JSON5 object.
FossilOrigin-Name: f56528d413d8e622f7c4f18b2f9f2e620bfb441c020461299b35a90072ee6c13
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/json.c b/src/json.c index 6bac63ec5..1152d9f91 100644 --- a/src/json.c +++ b/src/json.c @@ -726,17 +726,11 @@ static void jsonReturn( break; } case JSON_STRING: { -#if 0 /* Never happens because JNODE_RAW is only set by json_set(), - ** json_insert() and json_replace() and those routines do not - ** call jsonReturn() */ if( pNode->jnFlags & JNODE_RAW ){ assert( pNode->eU==1 ); sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, SQLITE_TRANSIENT); - }else -#endif - assert( (pNode->jnFlags & JNODE_RAW)==0 ); - if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){ + }else if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){ /* JSON formatted without any backslash-escapes */ assert( pNode->eU==1 ); sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2, @@ -2872,14 +2866,16 @@ static void jsonAppendObjectPathElement( assert( pNode->eU==1 ); z = pNode->u.zJContent; nn = pNode->n; - assert( nn>=2 ); - assert( z[0]=='"' ); - assert( z[nn-1]=='"' ); - if( nn>2 && sqlite3Isalpha(z[1]) ){ - for(jj=2; jj<nn-1 && sqlite3Isalnum(z[jj]); jj++){} - if( jj==nn-1 ){ - z++; - nn -= 2; + if( (pNode->jnFlags & JNODE_RAW)==0 ){ + assert( nn>=2 ); + assert( z[0]=='"' ); + assert( z[nn-1]=='"' ); + if( nn>2 && sqlite3Isalpha(z[1]) ){ + for(jj=2; jj<nn-1 && sqlite3Isalnum(z[jj]); jj++){} + if( jj==nn-1 ){ + z++; + nn -= 2; + } } } jsonPrintf(nn+2, pStr, ".%.*s", nn, z); |