Skip to content
Snippets Groups Projects
Commit 8231ef79 authored by Philip Scherer's avatar Philip Scherer
Browse files

Handle null objects in easy JSON converter

parent db64cc9b
No related branches found
No related tags found
1 merge request!254Add GUI for armem predictions to MemoryViewer
......@@ -33,35 +33,30 @@ namespace armarx::armem::gui::instance
TreeTypedJSONConverter::MapElements
TreeTypedJSONConverter::getObjectElements(DataInput& elementData, TypeInput& elementType)
{
std::map<std::string, std::pair<aron::data::VariantPtr, aron::type::VariantPtr>> ret;
auto data = aron::data::Dict::DynamicCastAndCheck(elementData);
auto type = aron::type::Object::DynamicCastAndCheck(elementType);
if (data)
{
for (const auto& [key, e] : data->getElements())
{
if (type && type->hasMemberType(key))
{
auto memberType = type->getMemberType(key);
ret.insert({key, {e, memberType}});
}
else
{
ret.insert({key, {e, nullptr}});
}
}
}
return ret;
return GetObjectElementsWithNullType(elementData, elementType);
}
void
TreeTypedJSONConverter::visitObjectOnEnter(DataInput& elementData, TypeInput& /*elementType*/)
TreeTypedJSONConverter::visitObjectOnEnter(DataInput& elementData, TypeInput& elementType)
{
std::string key = "";
aron::Path path;
if (elementData)
{
path = elementData->getPath();
}
else if (elementType)
{
path = elementType->getPath();
}
else
{
return;
}
try
{
key = elementData->getPath().getLastElement();
key = path.getLastElement();
}
catch (const aron::error::AronException& e)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment