diff options
author | drh <> | 2023-10-06 23:02:06 +0000 |
---|---|---|
committer | drh <> | 2023-10-06 23:02:06 +0000 |
commit | 11aa2adca34aed5b723e4772b39176aafc1da84a (patch) | |
tree | a4c20b4f8de4d5edf9734dd9711199dd21a62544 /src/json.c | |
parent | 6b8aa95c3c3f79cedb4fcaea84687c671642bcf9 (diff) | |
download | sqlite-11aa2adca34aed5b723e4772b39176aafc1da84a.tar.gz sqlite-11aa2adca34aed5b723e4772b39176aafc1da84a.zip |
Correct handling of "raw" strings in JSON. This requires three test-case
changes in TH3 to add double-quotes to the path outputs from json_tree().
The new behavior is correct, I believe.
FossilOrigin-Name: ab2bf3e3596dfa7566f4a130adeccbef4056c7321181112a875477193583f30c
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/json.c b/src/json.c index 25aa186e9..850f2bbf4 100644 --- a/src/json.c +++ b/src/json.c @@ -910,13 +910,7 @@ static void jsonRenderNodeAsText( case JSON_STRING: { assert( pNode->eU==1 ); if( pNode->jnFlags & JNODE_RAW ){ - if( pNode->jnFlags & JNODE_LABEL ){ - jsonAppendChar(pOut, '"'); - jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); - jsonAppendChar(pOut, '"'); - }else{ - jsonAppendString(pOut, pNode->u.zJContent, pNode->n); - } + jsonAppendString(pOut, pNode->u.zJContent, pNode->n); }else if( pNode->jnFlags & JNODE_JSON5 ){ jsonAppendNormalizedString(pOut, pNode->u.zJContent, pNode->n); }else{ @@ -1564,7 +1558,7 @@ json_parse_restart: ){ k++; } - jsonParseAddNode(pParse, JSON_STRING | (JNODE_RAW<<8), k-j, &z[j]); + jsonParseAddNode(pParse, JSON_STRING, k-j, &z[j]); pParse->hasNonstd = 1; x = k; }else{ @@ -3373,6 +3367,10 @@ static u32 jsonRenderBlob( jsonAppendChar(pOut, '"'); break; } + case JSONB_TEXTRAW: { + jsonAppendString(pOut, (const char*)&pParse->aBlob[i+n], sz); + break; + } case JSONB_ARRAY: { jsonAppendChar(pOut, '['); j = i+n; @@ -3481,10 +3479,14 @@ static int jsonParseValueFromBlob(JsonParse *pParse, u32 i){ jsonParseAddNode(pParse, JSON_REAL | (JNODE_JSON5<<8), sz, zPayload); break; } - case JSONB_TEXT: { + case JSONB_TEXTRAW: { jsonParseAddNode(pParse, JSON_STRING | (JNODE_RAW<<8), sz, zPayload); break; } + case JSONB_TEXT: { + jsonParseAddNode(pParse, JSON_STRING, sz, zPayload); + break; + } case JSONB_TEXTJ: { jsonParseAddNode(pParse, JSON_STRING | (JNODE_ESCAPE<<8), sz, zPayload); break; @@ -3495,10 +3497,6 @@ static int jsonParseValueFromBlob(JsonParse *pParse, u32 i){ sz, zPayload); break; } - case JSONB_TEXTRAW: { - jsonParseAddNode(pParse, JSON_STRING | (JNODE_RAW<<8), sz, zPayload); - break; - } case JSONB_ARRAY: { int iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); u32 j = i+x; @@ -3529,6 +3527,10 @@ static int jsonParseValueFromBlob(JsonParse *pParse, u32 i){ if( k&1 ) return -1; break; } + default: { + pParse->nErr++; + break; + } } return i+x+sz; } |