DICOM to JSON

174 views
Skip to first unread message

ncwo...@gmail.com

unread,
Dec 3, 2017, 10:58:40 AM12/3/17
to Fellow Oak DICOM
Hi,

I am using  ConvertDicomToXML to convert DICOM to XML 

Is it possible to convert DICOM to JSON?

Thanks 

reini....@aon.at

unread,
Dec 21, 2017, 4:43:39 PM12/21/17
to Fellow Oak DICOM
Of course you can first convert Dicom to XML and then use an package like json.net to convert the xml to json :-)

There is also a class JsonDicomConverter in namespace Dicom.Serialization. this should be what you are looking for.

ncwo...@gmail.com

unread,
Dec 28, 2017, 10:14:05 AM12/28/17
to Fellow Oak DICOM
Thanks!

Following your advise I am trying to use JsonDicomConverter.cs BUT, I get an error at ParseTag method return type :

 internal static DicomTag ParseTag(string tagstr)
        {
            if (Regex.IsMatch(tagstr, @"\A\b[0-9a-fA-F]+\b\Z"))
            {
                var group = Convert.ToUInt16(tagstr.Substring(0, 4), 16);
                var element = Convert.ToUInt16(tagstr.Substring(4), 16);
                var tag = new DicomTag(group, element);
                return tag;
            }

            return DicomDictionary.Default[tagstr]; // error cannot convert string to Dicom.Dicom.DicomTag
        }


Thanks in advance
Message has been deleted

reini....@aon.at

unread,
Dec 31, 2017, 4:23:56 AM12/31/17
to Fellow Oak DICOM
I see. Did you reference to the latest fo-dicom release?
because there was a change on 29.05.2017 by Rickard Holmberg in DicomDictionary that also affected JsonDicomConverter. This was some weeks after releasing 3.1.0-alpha

you could dowlnoad the complete development branch and build with that. or you browse in github to the version before this change and use this JsonDicomConverter.cs: https://github.com/fo-dicom/fo-dicom/blob/c912a0b7f1257fc5fbe8059f7175372d49c2804e/Serialization/Json/JsonDicomConverter.cs
by the way, the change was "only" some performance improvement, so no worry to use the older version of JsonDicomConverter. there is no known bug.
Reply all
Reply to author
Forward
0 new messages