Skip to content

Commit

Permalink
json: correct representation of multi-dimensional arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
linev authored and mueschel committed Jan 13, 2015
1 parent 7326b2d commit 7627fb7
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions net/http/src/TBufferJSON.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,7 @@ TString TBufferJSON::JsonWriteMember(const void *ptr, TDataMember *member,
while (cnt >= 0) {
if (indexes[cnt] >= member->GetMaxIndex(cnt)) {
fOutBuffer.Append(" ]");
indexes[cnt] = 0;
cnt--;
indexes[cnt--] = 0;
if (cnt >= 0) indexes[cnt]++;
continue;
}
Expand All @@ -416,8 +415,6 @@ TString TBufferJSON::JsonWriteMember(const void *ptr, TDataMember *member,

fValue.Clear();

WriteFastArray((Int_t *)ptr + shift, len);

switch (tid) {
case kChar_t:
WriteFastArray((Char_t *)ptr + shift, len);
Expand Down Expand Up @@ -484,8 +481,7 @@ TString TBufferJSON::JsonWriteMember(const void *ptr, TDataMember *member,
}

fOutBuffer.Append(fValue);
cnt--;
indexes[cnt]++;
indexes[--cnt]++;
}
}

Expand Down Expand Up @@ -2129,8 +2125,30 @@ void TBufferJSON::WriteArrayDouble32(const Double_t *d, Int_t n,
} \
PerformPostProcessing(Stack(0), elem); \
} \
} \
else { \
} else \
if ((elem!=0) && (elem->GetArrayDim()>1) && (elem->GetArrayLength()==n)) { \
TArrayI indexes(elem->GetArrayDim() - 1); \
indexes.Reset(0); \
Int_t cnt = 0; \
while (cnt >= 0) { \
if (indexes[cnt] >= elem->GetMaxIndex(cnt)) { \
fValue.Append("]"); \
indexes[cnt--] = 0; \
if (cnt >= 0) indexes[cnt]++; \
continue; \
} \
fValue.Append(indexes[cnt] == 0 ? "[" : fArraySepar.Data()); \
if (++cnt == indexes.GetSize()) { \
Int_t shift = 0; \
for (Int_t k = 0; k < indexes.GetSize(); k++) \
shift = shift * elem->GetMaxIndex(k) + indexes[k]; \
Int_t len = elem->GetMaxIndex(indexes.GetSize()); \
shift *= len; \
TJSONWriteArrayContent((vname+shift), len); \
indexes[--cnt]++; \
} \
} \
} else { \
TJSONWriteArrayContent(vname, n); \
} \
}
Expand Down

0 comments on commit 7627fb7

Please sign in to comment.