From 1f89317c07efb75b17748d8f582a26ca8090a73e Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 16 Oct 2012 13:55:34 -0700 Subject: [PATCH] Fix JSON for arrays. --- src/SerializedObject.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/SerializedObject.cpp b/src/SerializedObject.cpp index a7ce22ba43..0ba32127b4 100644 --- a/src/SerializedObject.cpp +++ b/src/SerializedObject.cpp @@ -831,8 +831,20 @@ std::string STArray::getText() const Json::Value STArray::getJson(int p) const { Json::Value v = Json::arrayValue; - BOOST_FOREACH(const STObject& o, value) - v.append(o.getJson(p)); + int index = 1; + BOOST_FOREACH(const STObject& object, value) + { + if (object.getSType() != STI_NOTPRESENT) + { + Json::Value inner = Json::objectValue; + if (!object.getFName().hasName()) + inner[lexical_cast_i(index)] = object.getJson(p); + else + inner[object.getName()] = object.getJson(p); + v.append(inner); + index++; + } + } return v; }