Been running into a weird buggish issue. I have a method that basically builds a big JSON object, field by field, then returns it. It worked when I test it in console.

Once provisioned, however, I got a strange “Unable to convert Javascript object to string” error. I’m assuming that somewhere during execution, the JSON string was interpreted as a JS object (although I made sure that fields were defined with strings, e.g. { ‘field’: ‘value’ } not { field: ‘value’ } or field.value). I was able to deduce that the error was actually triggered when the function returned–everything up to that point still worked fine.

I was able to fix this by enclosing the return value in JSON.stringify(). Any ideas what went wrong?