On Fri, Sep 11, 2015 at 8:58 AM, Richard Hipp <drh at sqlite.org> wrote:
> Draft documentation for the current design of JSON support in SQLite > can be seen on-line at > > https://www.sqlite.org/draft/json1.html > > Your feedback is encouraged. > > All features described in the document above are implemented and > working in the latest trunk version of SQLite, which you can download > in source-code form from https://www.sqlite.org/src/timeline?y=ci and > compile yourself using instructions found at > https://www.sqlite.org/src/doc/trunk/README.md Given json_each(), you can transform json into a table-alike feature. I found myself wondering if there was anything which could easily take a result set and convert it to json. I can see that something like this could convert a result row into a json object: SELECT json_object("c", c, "d", d", ...) FROM ...; but it's not obvious to me how to feed all of those json objects to json_array(). You could do things like string together a bunch of sub-queries, I suppose. Riffing off group_concat(), maybe something like this makes sense: SELECT json_group_array(json_object("c", c, "d", d)) FROM t WHERE <condition> GROUP BY <something>; Now, if you were to ask me what I would use that for ... I would come up blank. I mostly suggested it because it feels like there is a piece missing. ===break=== Someone else mentioned json_array_index() - while I agree that json_extract() can do the same thing, it does somewhat feel like a natural thing to have json_array_index(). And it could optionally support slicing: json_array_index('[1,2,3,4]', 1) -> 2 json_array_index('[1,2,3,4]', 2, 2) -> '[3,4]' Though I suppose something like: json_extract('[1,2,3,4]', '$[0,2..3]') might be a cleaner place to put a slicing syntax. Of course if I went there, I'd also wonder about '$.{a,c}' as syntax to generate an object slice. Maybe v+1 for this kind of thing. ===break=== In the table for json_insert/replace/set(), I suspect the last row should have function json_set(). -scott