[SOLVED] Can I make json attribute inside another json attribute?

I want to do something like this, but get playcanvas error:
attribute `events` invalid schema: field `params` has invalid type

SomeClass.attributes.add(
    "events",
    {
        type: "json",
        schema: [{
            name: "entity",
            type: "entity"
        }, {
            name: "event",
            type: "string"
        }, {
            name: "params",
            type: "json",
            schema: [{
                name: "type",
                type: "string"
            }, {
                name: "value",
                type: "string"
            }],
        }],
        array: true
    }
);

Hi @Gradess,

No, currently only one level deep JSON attributes, from the manual page:

NOTE: We currently do not support defining JSON attributes as children of other JSON attributes. You can only go 1 level deep when defining a JSON attribute.

https://developer.playcanvas.com/en/user-manual/scripting/script-attributes/

2 Likes

Oops, didn’t see that, thank you!

1 Like

2 posts were split to a new topic: Referencing JSON from a JSON script attribute