Phoenix generators and json structure

Hey there!

I was generating some endpoints using mix phx.gen.json and the json format it uses is

POST /endpoint
{
    "model": {
        "attr1": "hello",
        "attr2": "good bye"
    }
}

RESPONSE
{
    "data": {
        "id": 1,
        "attr1": "hello",
        "attr2": "good bye"
    }
}

So Im wondering if Phoenix is following some standard to come up with that structure, or if there is a reason/discussion around it.

Thanks!

1 Like