Windows specific Bug in OspeyJob.m file and a fix

Dear Osprey team,
When using the Osprey GUI to create a job file on a Windows system, there is a bug that causes the GUI to crash with this error

Error using jsondecode
JSON syntax error at line 26, column 15 (character 553): escape character ‘\U’ is not valid.

Error in OspreyJob (line 225)
jobStruct = jsondecode(str);

Error in CreateOspreyJob_app/CREATEJOBButtonPushed (line 471)
MRSCont = OspreyJob(jobm,1);

Error in appdesigner.internal.service.AppManagementService/executeCallback (line 138)
callback(appOrUserComponent, event);

Error in matlab.apps.AppBase>@(source,event)executeCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event) (line 63)
newCallback = @(source, event)executeCallback(appdesigner.internal.service.AppManagementService.instance(), …

Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback
Error while evaluating DestroyedObject PrivateButtonPushedFcn.

It seems the error arises due to the fact that the file seperator on windows systems is ‘\’ which in json is an “escape” character, so to allow the ‘\’ to work as a file seperator you need to ‘escape’ before it with a ‘\’ so use ‘\\’ instead.
The partner of one of my students (Billy Hayes) made a simple one line edit to the OspreyJob.m file by adding

str = replace(str, ‘\’, ‘\\’);

just after line 220

str = char(raw’);

This may be useful for other 'beginer" sites that are using Windows and want to start with the GUI version of things.
(Note, even here in this forum when writing this post I had to escape the \ in the post editor to allow it to show in the HTML formatted post.)


1 Like


just stumbled across this today when I was trying to compile Osprey on Windows. Thanks for the hint!

I’ll include this in the next push to GitHub.


Hi @Helge ,

one more bug from the Windows side (and likely Mac side) that arises when using the GUi to build and load a jobfile for more than one file: as put by the person (Billy Hayes) who found it:

"Hiya Paul, it was some oversight with the way the textbox resized in the GUI itself for displaying the files you’ve selected once you clicked them. Longer file path names would increase the textbox size, and this would append spaces onto the smaller filepaths already selected.

I fixed it by adding one other line in the OspreyJob.m file after the other addition. This one used pattern matching.

str = replace(str, whitespacePattern + ‘"’, ‘"’);

Similar to the last fix, but to make sure you don’t remove spaces in the middle of the file path the whitespaces need to be followed by a " character (i.e the end of the filepath) to be removed

The whitespacePattern is used instead of just a space character because there could be a variable number of spaces depending on how different the file lengths are

This and the last fix combined means the GUI is fully useable now though, with no errors, regardless of the number of files!"

We hope that helps!



Thanks so much for reporting and fixing this! I’ll update the code accordingly.