bug in DcmFileFormat::writeJson

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Shaeto
Posts: 140
Joined: Tue, 2009-01-20, 17:50
Location: CA, USA
Contact:

bug in DcmFileFormat::writeJson

#1 Post by Shaeto » Thu, 2021-01-28, 10:34

version 3.6.6 (and master)

method DcmFileFormat::writeJson does not print "," between meta and main dataset

i used simplest fix (didn't want to use stringstream)

if (dset && status.good())
{
if (metinf && metinf->card())
out << ",";
status = dset->writeJsonExt(out, format, OFFalse, OFFalse);
}

thanks!

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1280
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: bug in DcmFileFormat::writeJson

#2 Post by Marco Eichelberg » Mon, 2021-02-01, 13:47

Thank you for the bug report. I can confirm that I was able to reproduce it. I have no idea how this managed to slip through - I am fairly certain that I had fixed that error before.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1280
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: bug in DcmFileFormat::writeJson

#3 Post by Marco Eichelberg » Fri, 2021-02-05, 16:36

The bug fix has been committed now in commit #d03f56b1e and should appear in the public git in a couple of days. Here's the diff log:

Code: Select all

--- a/dcmdata/libsrc/dcfilefo.cc
+++ b/dcmdata/libsrc/dcfilefo.cc
@@ -245,10 +245,10 @@ OFCondition DcmFileFormat::writeJson(STD_NAMESPACE ostream &out,
         if (metinf)
         {
           status = metinf->writeJsonExt(out, format, OFFalse, OFFalse);
-          out << format.newline();
         }
         if (dset && status.good())
         {
+            if (metinf && (metinf->card() > 0) && (dset->card() > 0)) out << "," << format.newline();
             status = dset->writeJsonExt(out, format, OFFalse, OFFalse);
         }
         out << format.newline() << format.indent() << "}" << format.newline();

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest