title: How to parse struct object in the response from detectIntent of dialogflow v2?
body: <p>I would like to know the best practice to parse the response of detectIntent of dialogflow v2.</p>
  
  <p>The response of dialogflow v2 includes <a href="https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Struct" rel="noreferrer">struct</a> object which is defined in Protocol Buffer. For example, parameters in <a href="https://dialogflow.com/docs/reference/api-v2/rest/Shared.Types/QueryResult" rel="noreferrer">queryResult</a>.</p>
  
  <p>I know it is possible to parse it by using <a href="https://github.com/dialogflow/dialogflow-nodejs-client-v2/blob/master/samples/structjson.js" rel="noreferrer">structToJson</a> which is included in dialogflow v2 SDK  for Node.js as sample code. So the my current code is looks like this.</p>
  
  <pre><code>const dialogflow = require("dialogflow");
  const structjson = require("./dialogflow/structjson");
  
  identify_intent(sentence, options){
      const session_path = this._sessions_client.sessionPath(this._project_id, options.session_id);
  
      // The text query request.
      const request = {
          session: session_path,
          queryInput: {
              text: {
                  text: sentence,
                  languageCode: this._language
              }
          }
      };
  
      // Send request and log result
      return this._sessions_client.detectIntent(request).then(responses =&gt; {
          let result = responses[0].queryResult;
  
          if (result.parameters){
              result.parameters = structjson.structProtoToJson(result.parameters);
          }
  
          return result;
      });
  }
  </code></pre>
  
  <p>I'm parsing the response manually by using structProtoToJson() following the <a href="https://github.com/dialogflow/dialogflow-nodejs-client-v2/blob/master/samples/detect.js" rel="noreferrer">sample code</a> but it is not practical since I have to do it not only for parameters but also fo fulfillment and other object as well which is formatted in struct.</p>
  
  <p>I'm wondering what is the best practice to parse the response from detectIntent in Node.js app.</p>