diff options
author | drh <drh@noemail.net> | 2015-09-11 00:06:41 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-09-11 00:06:41 +0000 |
commit | f5ddb9c214b5e6237e9bfb878aa21cfd2ef129fc (patch) | |
tree | f3f2f995669f51045636d3a368709c4b403bf413 /test/json101.test | |
parent | cf94f179647fd7573f58ad40bbf5603a77035a73 (diff) | |
download | sqlite-f5ddb9c214b5e6237e9bfb878aa21cfd2ef129fc.tar.gz sqlite-f5ddb9c214b5e6237e9bfb878aa21cfd2ef129fc.zip |
Take out the goofy '$$' path syntax. Instead, use subtypes to communicate when
a string is JSON. Add the json() function that validates and minifies the
JSON and sets the appropriate subtype.
FossilOrigin-Name: 8a80d6459e246ec1b38325e1cbd1e862157138b3
Diffstat (limited to 'test/json101.test')
-rw-r--r-- | test/json101.test | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/json101.test b/test/json101.test index 1a84a5fc5..9543ccfd2 100644 --- a/test/json101.test +++ b/test/json101.test @@ -16,9 +16,21 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl load_static_extension db json -do_execsql_test json1-1.1 { +do_execsql_test json1-1.1.00 { SELECT json_array(1,2.5,null,'hello'); } {[1,2.5,null,"hello"]} +do_execsql_test json1-1.1.01 { + SELECT json_array(1,'{"abc":2.5,"def":null,"ghi":hello}',99); + -- the second term goes in as a string: +} {[1,"{\\"abc\\":2.5,\\"def\\":null,\\"ghi\\":hello}",99]} +do_execsql_test json1-1.1.02 { + SELECT json_array(1,json('{"abc":2.5,"def":null,"ghi":"hello"}'),99); + -- the second term goes in as JSON +} {[1,{"abc":2.5,"def":null,"ghi":"hello"},99]} +do_execsql_test json1-1.1.03 { + SELECT json_array(1,json_object('abc',2.5,'def',null,'ghi','hello'),99); + -- the second term goes in as JSON +} {[1,{"abc":2.5,"def":null,"ghi":"hello"},99]} do_execsql_test json1-1.2 { SELECT hex(json_array('String "\ Test')); } {5B22537472696E67205C225C5C2054657374225D} @@ -54,13 +66,13 @@ do_execsql_test json1-3.1 { SELECT json_replace('{"a":1,"b":2}','$.a','[3,4,5]'); } {{{"a":"[3,4,5]","b":2}}} do_execsql_test json1-3.2 { - SELECT json_replace('{"a":1,"b":2}','$$.a','[3,4,5]'); + SELECT json_replace('{"a":1,"b":2}','$.a',json('[3,4,5]')); } {{{"a":[3,4,5],"b":2}}} do_execsql_test json1-3.3 { SELECT json_type(json_set('{"a":1,"b":2}','$.b','{"x":3,"y":4}'),'$.b'); } {text} do_execsql_test json1-3.4 { - SELECT json_type(json_set('{"a":1,"b":2}','$$.b','{"x":3,"y":4}'),'$.b'); + SELECT json_type(json_set('{"a":1,"b":2}','$.b',json('{"x":3,"y":4}')),'$.b'); } {object} # Per rfc7159, any JSON value is allowed at the top level, and whitespace |