json_group_array( json_object())

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

json_group_array( json_object())

ingo
The following:

json_object (
  'data', json_group_array(
     json_object(
       'type', type,
       'id', notebook_id,
       'attributes', json_object(
          'book', book,
          'total_notes', total_notes
       ), ...etc

results in:

{"data":"[{\"type\":\"notebook\",\"id\":2,\"attributes\":{\"book\":\"brew\",\...
etc

the array is a string?

besides manually constructing with:
 || json_quotes('data')
 || ":["
 || group_concat(
        json_object( )
    )

how should it be done properly in one go?

TIA,

ingo
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: json_group_array( json_object())

Richard Hipp-3
On 7/5/19, ingo <[hidden email]> wrote:

> The following:
>
> json_object (
>   'data', json_group_array(
>      json_object(
>        'type', type,
>        'id', notebook_id,
>        'attributes', json_object(
>           'book', book,
>           'total_notes', total_notes
>        ), ...etc
>
> results in:
>
> {"data":"[{\"type\":\"notebook\",\"id\":2,\"attributes\":{\"book\":\"brew\",\...

Unable to repro the problem.

Can you please send a complete example?  Also send the version number
of SQLite that you are running.

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: json_group_array( json_object())

ingo


On 5-7-2019 20:14, Richard Hipp wrote:
> Can you please send a complete example?

While preparing that the problem was resolved. A search showed that a
wrong concatenation || further down caused  this result.

Something I noticed before when working with json is that my errors in
the code result in strange results and not in an error.


Thanks Richard,

Ingo
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users