From 72332fe9ad3f225866c57918cbe35c7398e02094 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Thu, 27 Oct 2016 13:38:31 +0200 Subject: [PATCH] json: correctly handle array of special objects In case of array of STL vectors like std::vector fMember[5]; One should flush value before writing array Signed-off-by: Sergey Linev --- io/io/src/TBufferJSON.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/io/io/src/TBufferJSON.cxx b/io/io/src/TBufferJSON.cxx index e464b4e05f706..51600b5d33d3e 100644 --- a/io/io/src/TBufferJSON.cxx +++ b/io/io/src/TBufferJSON.cxx @@ -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) { @@ -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 { @@ -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(); + } } }