martinzink commented on code in PR #1552:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1552#discussion_r1172786389


##########
extensions/windows-event-log/wel/JSONUtils.cpp:
##########
@@ -135,28 +158,33 @@ rapidjson::Document toJSONImpl(const pugi::xml_node& 
root, bool flatten) {
 
   {
     auto eventData_xml = event_xml.child("EventData");
-    // create EventData subarray even if flatten requested
-    doc.AddMember("EventData", rapidjson::kArrayType, doc.GetAllocator());
-    for (const auto& data : eventData_xml.children()) {
-      auto name_attr = data.attribute("Name");
-      rapidjson::Value item(rapidjson::kObjectType);
-      item.AddMember("Name", rapidjson::StringRef(name_attr.value()), 
doc.GetAllocator());
-      item.AddMember("Content", rapidjson::StringRef(data.text().get()), 
doc.GetAllocator());
-      item.AddMember("Type", rapidjson::StringRef(data.name()), 
doc.GetAllocator());
-      // we need to query EventData because a reference to it wouldn't be 
stable, as we
-      // possibly add members to its parent which could result in reallocation
-      doc["EventData"].PushBack(item, doc.GetAllocator());
-      // check collision
-      if (flatten && !name_attr.empty() && !doc.HasMember(name_attr.value())) {
-        doc.AddMember(rapidjson::StringRef(name_attr.value()), 
rapidjson::StringRef(data.text().get()), doc.GetAllocator());
+    if (flatten) {
+      for (const auto& event_data_child : eventData_xml.children()) {
+        std::string key = "EventData";
+        if (auto name_attr = event_data_child.attribute("Name").value(); 
strlen(name_attr)) {
+          key = utils::StringUtils::join_pack(key, ".", name_attr);

Review Comment:
   good idea, I've included this 👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to