Skip to content

Commit

Permalink
json: correctly handle array of special objects
Browse files Browse the repository at this point in the history
In case of array of STL vectors like

    std::vector<double>  fMember[5];

One should flush value before writing array

Signed-off-by: Sergey Linev <[email protected]>
  • Loading branch information
linev authored and pcanal committed Nov 7, 2016
1 parent e2c5725 commit 72332fe
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions io/io/src/TBufferJSON.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,11 @@ void TBufferJSON::WriteFastArray(void *start, const TClass *cl, Int_t n,
if (j > 0) AppendOutput(fArraySepar.Data());

JsonWriteObject(obj, cl, kFALSE);

if ((n > 1) && (fValue.Length() > 0)) {
AppendOutput(fValue.Data());
fValue.Clear();
}
}

if (n > 1) {
Expand Down Expand Up @@ -2496,6 +2501,10 @@ Int_t TBufferJSON::WriteFastArray(void **start, const TClass *cl, Int_t n,
for (Int_t j = 0; j < n; j++) {
if (j > 0) AppendOutput(fArraySepar.Data());
res |= WriteObjectAny(start[j], cl);
if ((n > 1) && (fValue.Length() > 0)) {
AppendOutput(fValue.Data());
fValue.Clear();
}
}

} else {
Expand All @@ -2507,6 +2516,11 @@ Int_t TBufferJSON::WriteFastArray(void **start, const TClass *cl, Int_t n,
if (!start[j]) start[j] = ((TClass *)cl)->New();
// ((TClass*)cl)->Streamer(start[j],*this);
JsonWriteObject(start[j], cl, kFALSE);

if ((n > 1) && (fValue.Length() > 0)) {
AppendOutput(fValue.Data());
fValue.Clear();
}
}
}

Expand Down

0 comments on commit 72332fe

Please sign in to comment.