The third entry in savejson is the file in which you need to save the received JSON data. In the example you provided
savejson('',x,'data/matlabData.json')
This is an attempt to create a matlabData.json file in the data folder. savejson does not work because the data folder does not exist and therefore the file cannot be created.
You can create a data folder
mkdir('data') savejson('', x, fullfile('data', 'matlabData.json'))
Or you can use your own file name, which does not require a folder
savejson('', x, 'matlabData.json')
Suver source share