Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string content is not escaped appropriately in json output #131

Closed
satra opened this issue Sep 16, 2017 · 2 comments
Closed

string content is not escaped appropriately in json output #131

satra opened this issue Sep 16, 2017 · 2 comments

Comments

@satra
Copy link

satra commented Sep 16, 2017

on a sequence i was testing the json bids output returns:

{
	"PulseSequenceDetails": "%CustomerSeq%\ep2d_diff_MGH"
}

however, the \ should be escaped \\

{
	"PulseSequenceDetails": "%CustomerSeq%\\ep2d_diff_MGH"
}

more generally the json should be validated before writing.

@satra
Copy link
Author

satra commented Sep 16, 2017

here is a bit of playing with this in python:

In [31]: a = { "PulseSequenceDetails": "%CustomerSeq%\ep2d_diff_MGH"}

In [32]: a
Out[32]: {'PulseSequenceDetails': '%CustomerSeq%\\ep2d_diff_MGH'}

In [33]: print(json.loads(json.dumps(a)))
{'PulseSequenceDetails': '%CustomerSeq%\\ep2d_diff_MGH'}

In [34]: print(json.loads(json.dumps(a))['PulseSequenceDetails'])
%CustomerSeq%\ep2d_diff_MGH

neurolabusc added a commit that referenced this issue Sep 17, 2017
@neurolabusc
Copy link
Collaborator

This was a recent regression that allows users to specify output folders as well as filenames (e.g. -f mydir/%p_%s, please check the latest code which restores previous behavior for json strings so that one gets "PulseSequenceDetails": "%CustomerSeq%_hcp_mbep2d_diff" instead of "PulseSequenceDetails": "%CustomerSeq%\hcp_mbep2d_diff". Note, instead of escaping special characters I replace them with an underline so string length does not change.

yarikoptic added a commit to neurodebian/dcm2niix that referenced this issue Jan 24, 2018
* tag 'v1.0.20170923': (43 commits)
  Increment version for new release
  Update dcm_qa submodule.
  Update dcm_qa submodule.
  Kludge for GEIIS violations https://www.nitrc.org/forum/message.php?msg_id=22370
  Fix file permissions
  Use ReconMatrixPE variable and update some inline comments
  @xjqian & @mharms tags BaseResolution, PhaseResolution, VendorReportedEchoSpacing, DerivedVendorReportedEchoSpacing rordenlab#130
  mharms suggestions for  rordenlab#130
  Partial fix for rordenlab#132
  Fix for rordenlab#131 (comment)
  bandwidthPerPixelCorrected from Dr. Junqian (Gordon) Xu rordenlab#130
  Add PhaseOversampling to BIDS
  BIDS Interpolation2D, RectangularFOV, improve ReadoutTime rordenlab#130
  TotalReadoutTime iPAT vs partial Fourier: rordenlab#130
  Move AsciiCsa to end of BIDS
  Eliminate AppVeyor compiler warnings
  Remove EchoTrainDuration and EPIFactor: rordenlab#127
  BIDS cleanup
  Reorder items in BIDS as suggested by Michael Harms
  Report Partial Fourier in BIDS json
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants