bids-matlab icon indicating copy to clipboard operation
bids-matlab copied to clipboard

[BUG] jsondecode failure

Open Remi-Gau opened this issue 3 years ago • 5 comments

very edge case

from https://openneuro.org/datasets/ds003216/versions/2.1.5/

json_file: ds003216/sub-02/ses-02/func/sub-02_ses-02_task-tapping_run-05_cbv.json

Many warning and eventually this error

> In matlab.internal.json.makeStructure (line 4
[failing_json.txt](https://github.com/bids-standard/bids-matlab/files/8918450/failing_json.txt)
9)
  In bids.util.jsondecode (line 37) 
Error using cell2struct
Duplicate field name "CsaSeries_MrPhoenixProtocol_asCoilSelectMeas_0__aFFT_SCALE_10__"

Error in matlab.internal.json.makeStructure (line 49)
data = cell2struct(values, names, 1);

Error in bids.util.jsondecode (line 37)
    value = jsondecode(fileread(file));

File content: added as txt

Remi-Gau avatar Jun 16 '22 11:06 Remi-Gau

Check if JSONio fails on this too.

Remi-Gau avatar Jun 16 '22 11:06 Remi-Gau

That works for me with jsondecode from MATLAB R2021a and Octave and with JSONio. Which version are you using?

Also, I agree this is a valid JSON file but isn't it a bit odd for a fieldname? "CsaSeries.MrPhoenixProtocol.asCoilSelectMeas[0].aFFT_SCALE[10].flFactor": 0.0419083

gllmflndn avatar Jun 16 '22 18:06 gllmflndn

Which version are you using?

Matlab 2017a

Also, I agree this is a valid JSON file but isn't it a bit odd for a fieldname? "CsaSeries.MrPhoenixProtocol.asCoilSelectMeas[0].aFFT_SCALE[10].flFactor": 0.0419083

I don't decide how DICOM headers happen. :-p

Remi-Gau avatar Jun 17 '22 00:06 Remi-Gau

OK, I can confirm the issue: jsondecode was introduced in R2016b and it crashes with this JSON file in R2016b and R2017a. It's OK from R2017b onwards.

gllmflndn avatar Jun 17 '22 10:06 gllmflndn

Thanks a bunch for cross checking this.

Will add it in the doc.

Remi-Gau avatar Jun 17 '22 10:06 Remi-Gau