I have a js file that ends with
msg = JSON.stringify(result)
$.NSFileHandle.fileHandleWithStandardOutput.writeData(
$.NSString.alloc.initWithString(String(msg))
.dataUsingEncoding($.NSUTF8StringEncoding)
)
When I run the script from the terminal, it returns JSON that appears to be correctly formatted for Script Filter.
$ ~/Documents/myscript.js list
{"items":[{"uid":"1","title":"OptA","autocomplete":"OptA","subtitle":"OptA","arg":"1"},{"uid":"2","title":"OptB","autocomplete":"OptB","subtitle":"OptB","arg":"2"}]}
In Alfred, I created a workflow that contains a script filter. `Alfred filters results` is checked, language set to `bin/bash`, and it is configured to run my JS script:
~/Documents/myscript.js list
When I type the keyword into Alfred, the workflow is displayed but no list results are returned.
Alfred debugger returns
ERROR: Script Filter to Script to Notification[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON:
Error: Can't convert types.
I assume this means that whatever Alfred has received is not recognised as valid JSON, is this correct?
Is there a way to interrogate Alfred to inspect what has been received into the script filter?
Or is there a better way to debug this error?