Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Implementation/API/amc_api_handler_external.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ uint32_t CAPIHandler_External::handleEventRequest(CJSONWriter& writer, const std
newObject.copyFromObject (iIter->value);
writer.addObject(sValueName, newObject);
}
if (iIter->value.IsArray()) {
AMC::CJSONWriterArray newArray (writer);
newArray.copyFromArray (iIter->value);
writer.addArray(sValueName, newArray);
}

}

Expand Down
5 changes: 5 additions & 0 deletions Implementation/Core/amc_jsonwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ void CJSONWriterArray::addArray(CJSONWriterArray& array)
m_Value.PushBack(array.m_Value, m_allocator);
}

void CJSONWriterArray::copyFromArray(const rapidjson::Value& arrayValue)
{
m_Value.CopyFrom(arrayValue, m_allocator);
}



CJSONWriter::CJSONWriter()
Expand Down
2 changes: 2 additions & 0 deletions Implementation/Core/amc_jsonwriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ namespace AMC {

void addArray(CJSONWriterArray& array);

void copyFromArray(const rapidjson::Value& arrayValue);

bool isEmpty();

};
Expand Down
10 changes: 8 additions & 2 deletions Implementation/LibMCEnv/libmcenv_jsonarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ IJSONObject * CJSONArray::AddObjectValue()

jsonValue.SetObject();

auto pMember = &m_pInstance->PushBack(jsonValue, m_pDocument->GetAllocator());
m_pInstance->PushBack(jsonValue, m_pDocument->GetAllocator());

// Get pointer to the newly added element (last element in array)
auto pMember = &(*m_pInstance)[m_pInstance->Size() - 1];

return new CJSONObject(m_pDocument, pMember);
}
Expand All @@ -271,7 +274,10 @@ IJSONArray * CJSONArray::AddArrayValue()

jsonValue.SetArray();

auto pMember = &m_pInstance->PushBack(jsonValue, m_pDocument->GetAllocator());
m_pInstance->PushBack(jsonValue, m_pDocument->GetAllocator());

// Get pointer to the newly added element (last element in array)
auto pMember = &(*m_pInstance)[m_pInstance->Size() - 1];

return new CJSONArray(m_pDocument, pMember);
}
Expand Down