mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
New json_nextract() function that works like json_extract() except that it
returns NULL instead of raising an error if the first argument is not well-formed JSON. Or if the first argument is not well-formed JSON and the second argument is '$', then return the first argument quoted. The "->" and "->>" operators are converted to use json_nextract(). FossilOrigin-Name: dc00f5286d26524b149de071490320afaa203fec5777b3eb813f07963614861a
This commit is contained in:
@@ -72,6 +72,9 @@ do_execsql_test json102-250 {
|
||||
SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$');
|
||||
} {{{"a":2,"c":[4,5,{"f":7}]}}}
|
||||
do_execsql_test json102-251 {
|
||||
SELECT json_nextract('{"a":2,"c":[4,5,{"f":7}]}', '$');
|
||||
} {{{"a":2,"c":[4,5,{"f":7}]}}}
|
||||
do_execsql_test json102-252 {
|
||||
SELECT '{"a":2,"c":[4,5,{"f":7}]}' -> '$';
|
||||
} {{{"a":2,"c":[4,5,{"f":7}]}}}
|
||||
do_execsql_test json102-260 {
|
||||
@@ -83,6 +86,22 @@ do_execsql_test json102-261 {
|
||||
do_execsql_test json102-262 {
|
||||
SELECT '{"a":2,"c":[4,5,{"f":7}]}' -> 'c';
|
||||
} {{[4,5,{"f":7}]}}
|
||||
do_catchsql_test json102-265 {
|
||||
SELECT json_extract('[1,2,3', '$[2]');
|
||||
} {1 {malformed JSON}}
|
||||
do_catchsql_test json102-266 {
|
||||
SELECT json_nextract('[1,2,3', '$[2]');
|
||||
} {0 {{}}}
|
||||
do_catchsql_test json102-267 {
|
||||
SELECT json_extract('[1,2,3', '$');
|
||||
} {1 {malformed JSON}}
|
||||
do_catchsql_test json102-268 {
|
||||
SELECT json_nextract('[1,2,3', '$');
|
||||
} {0 {{"[1,2,3"}}}
|
||||
do_catchsql_test json102-269 {
|
||||
SELECT '[1,2,3' ->> '$';
|
||||
} {0 {{"[1,2,3"}}}
|
||||
|
||||
do_execsql_test json102-270 {
|
||||
SELECT json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2]');
|
||||
} {{{"f":7}}}
|
||||
|
||||
Reference in New Issue
Block a user