| 385 | } |
| 386 | |
| 387 | void mitk::PropertyList::FromJSON(const nlohmann::json& j) |
| 388 | { |
| 389 | mitk::CoreServicePointer<mitk::IPropertyDeserialization> service(mitk::CoreServices::GetPropertyDeserialization()); |
| 390 | PropertyMap properties; |
| 391 | |
| 392 | auto jObject = j.get<nlohmann::json::object_t>(); |
| 393 | |
| 394 | for (const auto& [type, serializedProperties] : jObject) |
| 395 | { |
| 396 | auto prototype = service->CreateInstance(type); |
| 397 | |
| 398 | if (prototype.IsNull()) |
| 399 | { |
| 400 | MITK_ERROR << "Cannot create instance(s) of class \"" << type << "\"!"; |
| 401 | continue; |
| 402 | } |
| 403 | |
| 404 | auto serializedPropertiesObject = serializedProperties.get<nlohmann::json::object_t>(); |
| 405 | |
| 406 | for (const auto& [name, serializedProperty] : serializedPropertiesObject) |
| 407 | { |
| 408 | BaseProperty::Pointer property = static_cast<BaseProperty*>(prototype->CreateAnother().GetPointer()); |
| 409 | property->FromJSON(serializedProperty); |
| 410 | properties[name] = property; |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | m_Properties = properties; |
| 415 | } |
| 416 | |
| 417 | nlohmann::json mitk::ConvertPropertyListToSelfContainedJson(const mitk::PropertyList* propertyList) |
| 418 | { |
no test coverage detected