From: drh Date: Wed, 12 Aug 2015 17:23:34 +0000 (+0000) Subject: Add the json_object() function. X-Git-Tag: version-3.9.0~204^2~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2032d6079352562bf29af8e7a05fdde8c04c7135;p=thirdparty%2Fsqlite.git Add the json_object() function. FossilOrigin-Name: 414a95f3b79359f167858b2325fd2be223569c66 --- diff --git a/ext/misc/json.c b/ext/misc/json.c index 53442a9c6a..8acbb9bf5f 100644 --- a/ext/misc/json.c +++ b/ext/misc/json.c @@ -194,7 +194,70 @@ static void jsonArrayFunc( } } jsonAppendRaw(&jx, "]", 1); - jsonResult(&jx); + jsonResult(&jx); +} + +/* +** Implementation of the json_object(NAME,VALUE,...) function. Return a JSON +** object that contains all name/value given in arguments. Or if any name +** is not a string or if any value is a BLOB, throw an error. +*/ +static void jsonObjectFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + int i; + Json jx; + char cSep = '{'; + const char *z; + u32 n; + + if( argc&1 ){ + sqlite3_result_error(context, "json_object() requires an even number " + "of arguments", -1); + return; + } + jsonInit(&jx, context); + for(i=0; i