I have a JSON object which looks like this:
string str = '[
{
"name": "data-input1",
"type": "Element [in]",
"description": "data-input1",
"getConnectorPosition": "function (element) { return {x: 0, y: Math.floor(element.rectangle.width / 2)} }"
},
{
"name": "data-output1",
"type": "Element [out] [array]",
"description": "data-output1",
"getConnectorPosition": "function (element) { return {x: Math.floor(element.rectangle.width), y: Math.floor(element.rectangle.height / 2)} }"
}
]';
and I'd like to parse this string into an object.
I receive this error:
Uncaught TypeError: string is not a function
when the method getConnectorPosition is invoked.
Reading previous questions I have understood that functions in JSON are not exactly "legal", and the error also suggests this.
How, exactly, can I correctly parse a JSON object which contains functions (as above) and then invoke those functions?