More Complex JSON from SQL Builder

33 views
Skip to first unread message

Hisnan Faudan Azmia

unread,
Apr 12, 2022, 11:21:52 PMApr 12
to Fusio
Hi, Chirstoph
is possible  SQL Builder, build JSON like this ? :

{
    "id": "5b8b9f8f-f9d6-4b8f-b8f9-f8f9f9f9f9f9f",
    "name": "Bart",
    "age": "10",
    "pets": {
        {
            "id": "f72f9f9f-f9f9-f9f9-f9f9-f9f9f9f9f9f9f",
            "name": "Lisa",
            "type": "Dog",
            "data": {
                "age": "10",
                "color": "Brown",
                "breed": "Labrador"
            }
        },
        {
            "id": "f72f9f9f-f9f9-f9f9-f9f9-f9f9f9f9f9f9f",
            "name": "Marge",
            "type": "Cat",
            "data": {
                "age": "10",
                "color": "Brown",
                "breed": "Tabby"
            }
        }
    }
}
i already tried, but the result :
{
    "id": "5b8b9f8f-f9d6-4b8f-b8f9-f8f9f9f9f9f9f",
    "name": "Bart",
    "age": "10",
    "pets": {
        {
            "id": "f72f9f9f-f9f9-f9f9-f9f9-f9f9f9f9f9f9f",
            "name": "Lisa",
            "type": "Dog",
            "data": {
                "age": "10",
                "color": "Brown",
                "breed": "Labrador"
            }
        }
    }
},
{
    "id": "5b8b9f8f-f9d6-4b8f-b8f9-f8f9f9f9f9f9f",
    "name": "Bart",
    "age": "10",
    "pets": {
        {
            "id": "f72f9f9f-f9f9-f9f9-f9f9-f9f9f9f9f9f9f",
            "name": "Marge",
            "type": "Cat",
            "data": {
                "age": "10",
                "color": "Brown",
                "breed": "Tabby"
            }
        }
    }
}

 i still  dont clear how sql builder works

Thanks, Hisnan F.A

Christoph Kappestein

unread,
Apr 13, 2022, 2:40:41 PMApr 13
to Fusio
Hi Hisnan,

yes, in general this should be possible, we have also an example at our documentation s.

It basically allows you to create a nested result from relational tables using a JSON format

best regards
Christoph

Hisnan Faudan Azmia

unread,
Apr 13, 2022, 11:28:28 PMApr 13
to Fusio
So I can build them like, sample from fusio-sample-cms ?
fusio-sample-cms/GetAll.php at master · apioo/fusio-sample-cms · GitHub

Christoph Kappestein

unread,
May 10, 2022, 2:04:31 PMMay 10
to Fusio
Yes this should be possible, of course inside PHP you have more flexibility but in general it should be possible to represent this as JSON.

best regards
Christoph
Reply all
Reply to author
Forward
0 new messages