[ 
https://issues.apache.org/jira/browse/MINIFICPP-114?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16257006#comment-16257006
 ] 

ASF GitHub Bot commented on MINIFICPP-114:
------------------------------------------

Github user achristianson commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/191#discussion_r151692781
  
    --- Diff: extensions/http-curl/protocols/RESTProtocol.cpp ---
    @@ -81,48 +93,117 @@ const C2Payload RESTProtocol::parseJsonResponse(const 
C2Payload &payload, const
       return std::move(C2Payload(payload.getOperation(), 
state::UpdateState::READ_ERROR, true));
     }
     
    -Json::Value RESTProtocol::serializeJsonPayload(Json::Value &json_root, 
const C2Payload &payload) {
    -  // get the name from the content
    -  Json::Value json_payload;
    -  std::map<std::string, std::vector<Json::Value>> children;
    -  for (const auto &nested_payload : payload.getNestedPayloads()) {
    -    Json::Value child_payload = serializeJsonPayload(json_payload, 
nested_payload);
    -    children[nested_payload.getLabel()].push_back(child_payload);
    -  }
    -  for (auto child_vector : children) {
    -    if (child_vector.second.size() > 1) {
    -      Json::Value children_json(Json::arrayValue);
    -      for (auto child : child_vector.second) {
    -        json_payload[child_vector.first] = child;
    -      }
    -    } else {
    -      if (child_vector.second.size() == 1) {
    -        if (child_vector.second.at(0).isMember(child_vector.first)) {
    -          json_payload[child_vector.first] = 
child_vector.second.at(0)[child_vector.first];
    -        } else {
    -          json_payload[child_vector.first] = child_vector.second.at(0);
    -        }
    -      }
    -    }
    -  }
    +void setJsonStr(const std::string& key, const std::string& value, 
rapidjson::Value& parent, rapidjson::Document::AllocatorType& alloc) { // NOLINT
    +  rapidjson::Value keyVal;
    +  rapidjson::Value valueVal;
    +  const char* c_key = key.c_str();
    +  const char* c_val = value.c_str();
     
    +  keyVal.SetString(c_key, key.length()), alloc;
    +  valueVal.SetString(c_val, value.length(), alloc);
    +
    +  parent.AddMember(keyVal, valueVal, alloc);
    +}
    +
    +rapidjson::Value getStringValue(const std::string& value, 
rapidjson::Document::AllocatorType& alloc) { // NOLINT
    +  rapidjson::Value Val;
    --- End diff --
    
    IMO we should only use macros where really necessary, so the code can be 
clearer and easier to read.


> Consolidate JSON API use to RapidJSON
> -------------------------------------
>
>                 Key: MINIFICPP-114
>                 URL: https://issues.apache.org/jira/browse/MINIFICPP-114
>             Project: NiFi MiNiFi C++
>          Issue Type: Improvement
>            Reporter: John Reynolds
>            Assignee: John Reynolds
>
> MiNiFi was updated with new dependencies to jsoncpp: 
> SiteToSiteProvenanceReportingTask
> Performance observations indicate significant improvements with RapidJSON vs. 
> jsoncpp.  Convert all use of jsoncpp to RapidJSON where applicable.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to