I\'m writing an asset management application. It lets users store arbitrary asset attributes by adding an html control such as a text field, select menu, etc. to the asset. A JS
The problem is arising from the way your document is structured. attribute.data
is both a string/array of strings and a full, inner object. ES doesn't allow the "type" of a property to change.
Basically, you can't have this:
"data": [
"0d7e6233e5f48b4f55c5376bf00b1be5",
"0d7e6233e5f48b4f55c5376bf00d94cf"
],
and this:
"data":[
{
"text":"Button 1",
"checked":false
},
{
"text":"Button 2",
"checked":true
}
],
in the same document. The first instance of data
tells ES that "data is an array of strings". But then the second instance of data
says "Hey, I'm an object!", which is why ES is throwing an error.
You can sidestep this issue by explicitly declaring data
as an object and setting enabled: false, but this is probably not the solution you want (since that just tells ES to store data
as a text field, with no parsing.
The other option is to either restructure your data, or split data
into it's document (e.g. Parent/Child mapping)