diff options
author | drh <drh@noemail.net> | 2016-07-23 19:34:53 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-07-23 19:34:53 +0000 |
commit | 2ce26ff10a83039bd2c720f5e7cd585dfdaf3bee (patch) | |
tree | 01614428c91beca088d1a366c7478e67d2883e67 /ext/misc/json1.c | |
parent | eb09f6d788a76242003ff9dd42a7036c8656df0b (diff) | |
parent | 2ad96f5880fd77919571477dc0302cf763e527ff (diff) | |
download | sqlite-2ce26ff10a83039bd2c720f5e7cd585dfdaf3bee.tar.gz sqlite-2ce26ff10a83039bd2c720f5e7cd585dfdaf3bee.zip |
Add the json_quote() function to the JSON1 extension.
FossilOrigin-Name: 269892abf6e59c417729669cc764d1f237e093fd
Diffstat (limited to 'ext/misc/json1.c')
-rw-r--r-- | ext/misc/json1.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/misc/json1.c b/ext/misc/json1.c index 99d299c29..a9452b019 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -1212,6 +1212,25 @@ static void jsonTest1Func( ****************************************************************************/ /* +** Implementation of the json_QUOTE(VALUE) function. Return a JSON value +** corresponding to the SQL value input. Mostly this means putting +** double-quotes around strings and returning the unquoted string "null" +** when given a NULL input. +*/ +static void jsonQuoteFunc( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv +){ + JsonString jx; + + jsonInit(&jx, ctx); + jsonAppendValue(&jx, argv[0]); + jsonResult(&jx); + sqlite3_result_subtype(ctx, JSON_SUBTYPE); +} + +/* ** Implementation of the json_array(VALUE,...) function. Return a JSON ** array that contains all values given in arguments. Or if any argument ** is a BLOB, throw an error. @@ -2124,6 +2143,7 @@ int sqlite3Json1Init(sqlite3 *db){ { "json_extract", -1, 0, jsonExtractFunc }, { "json_insert", -1, 0, jsonSetFunc }, { "json_object", -1, 0, jsonObjectFunc }, + { "json_quote", 1, 0, jsonQuoteFunc }, { "json_remove", -1, 0, jsonRemoveFunc }, { "json_replace", -1, 0, jsonReplaceFunc }, { "json_set", -1, 1, jsonSetFunc }, |