This error is usaually the result of using a Java object or string where a javascript string is expected. The code wizard apis return java object/strings that need to be converted to JavaScript strings before being used in json. To convert a string add an empty string (''). Compare the differences in these three examples:
//Success
var myJavaScriptStringDate = '2014-02-03';
var somejson = {date:myJavaScriptStringDate};
JSON.stringify(somejson);
//Success
var myConvertedToJavaScriptString = '' + qie.formatDate('yyyy-mm-dd', new java.util.Date(qie.deduceDate(qie.getSystemDate()).getTime()));
somejson = {date:myConvertedToJavaScriptString};
JSON.stringify(somejson);
//Fails
var myJavaStringDate = qie.formatDate('yyyy-mm-dd', new java.util.Date(qie.deduceDate(qie.getSystemDate()).getTime()));
somejson = {date:myJavaStringDate};
JSON.stringify(somejson);
The first example is just a plain JavaScript string. The second is converted to JavaScript. The last one fails because the api returns a Java string that is not converted. The last two example are the same except for the empty string that forces it to be converted.
Also see this question:
https://www.qvera.com/kb/index.php/1/why-doesnt-my-string-have-a-replaceall-function?show=1#q1