title: How can I parse a JSON string containing functions?
body: <p>I have a JSON object which looks like this:</p>
  
  <pre><code>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)} }"
    }
    ]';
  </code></pre>
  
  <p>and I'd like to parse this string into an object.</p>
  
  <p>I receive this error:</p>
  
  <pre><code>Uncaught TypeError: string is not a function
  </code></pre>
  
  <p>when the method getConnectorPosition is invoked.</p>
  
  <p>Reading previous questions I have understood that functions in JSON are not exactly "legal", and the error also suggests this.</p>
  
  <p>How, exactly, can I correctly parse a JSON object which contains functions (as above) and then invoke those functions?</p>