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

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

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

    https://github.com/apache/nifi-minifi-cpp/pull/191#discussion_r151566198
  
    --- Diff: extensions/http-curl/protocols/RESTProtocol.cpp ---
    @@ -32,46 +33,57 @@ namespace minifi {
     namespace c2 {
     
     const C2Payload RESTProtocol::parseJsonResponse(const C2Payload &payload, 
const std::vector<char> &response) {
    -  Json::Reader reader;
    -  Json::Value root;
    +  rapidjson::Document root;
    +
       try {
    -    if (reader.parse(std::string(response.data(), response.size()), root)) 
{
    +    rapidjson::ParseResult ok = root.Parse(response.data(), 
response.size());
    +
    +    if (ok) {
           std::string requested_operation = getOperation(payload);
     
           std::string identifier;
    -      if (root.isMember("operationid")) {
    -        identifier = root["operationid"].asString();
    +      if (root.HasMember("operationid")) {
    +        identifier = root["operationid"].GetString();
           }
    -      if (root["operation"].asString() == requested_operation) {
    -        if (root["requested_operations"].size() == 0) {
    +
    +      if (root["operation"].GetString() == requested_operation) {
    +        if (root["requested_operations"].Size() == 0)
               return std::move(C2Payload(payload.getOperation(), 
state::UpdateState::READ_COMPLETE, true));
    -        }
    +
             C2Payload new_payload(payload.getOperation(), 
state::UpdateState::NESTED, true);
     
             new_payload.setIdentifier(identifier);
     
    -        for (const Json::Value& request : root["requested_operations"]) {
    -          Operation newOp = 
stringToOperation(request["operation"].asString());
    +        for (const rapidjson::Value& request : 
root["requested_operations"].GetArray()) {
    +          Operation newOp = 
stringToOperation(request["operation"].GetString());
               C2Payload nested_payload(newOp, 
state::UpdateState::READ_COMPLETE, true);
               C2ContentResponse new_command(newOp);
               new_command.delay = 0;
               new_command.required = true;
               new_command.ttl = -1;
    +
               // set the identifier if one exists
    -          if (request.isMember("operationid")) {
    -            new_command.ident = request["operationid"].asString();
    +          if (request.HasMember("operationid")) {
    +            if (request["operationid"].IsNumber())
    +              new_command.ident = 
std::to_string(request["operationid"].GetInt64());
    +            else if (request["operationid"].IsString())
    +              new_command.ident = request["operationid"].GetString();
    +            else
    +              throw(Exception(SITE2SITE_EXCEPTION, "Invalid type for 
operationid"));
    --- End diff --
    
    This exception should not be here. 


> 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