Problem: The same code and files that worked for jsondecode in 2018a and earlier stopped working in 2018b and beyond.
Exception: JSON text must be a character vector or a scalar non-missing string.
The attached article.txt file was written by
json = jsonencode(structObj);fID = fopen('./data/article.txt', 'w', 'n', 'UTF-8');fwrite(fID, json, 'char');fclose(fID);
I have attempted to read it back in by:
fileName = './data/article.txt';fID = fopen(fileName, 'r', 'n', 'UTF-8');readIn = native2unicode(fread(fID), 'UTF-8');value = jsondecode(readIn);fclose(fID);
This works in 2018a but throws the exceptions at the jsondecode line in 2018b and later
Best Answer