setDataProperty nested object

I’ve got a data model in which my data model consists of some top-level properties (e.g. “key” and “value”), but also some related properties that are contained in an object nested into the data model (e.g. “typeProp.owner” or “viewProp.fillColor”).
I can successfully use the model.setDataProperty method to set the properties for the top-level (e.g. “value”), but I cannot seem to figure out how to “reach into” an object contained to set one specific property therein (e.g. typeProp.owner). The data look kind of like this:

{ "key":1, "value": "whatever", "typeProps": { "owner": "example", "otherProps": "this object could have many more properties" }, "viewProps": { "fillColor": "green", "border": "black" } }

One approach that I think would work, but I’m trying to avoid, is to recreate the nested object in its entirety, changing the one sub-property in question, then calling

model.setDataProperty(node, "typeProp", newTypePropObjectContainingOnlyOneChangedSubProperty);

Is there a way instead to just tell setDataProperty to look for “owner” inside of the “typeProp”?

1 Like