Browse Source

HPCC-24304 Do not encode JSON ResponseEx's response child

Lucas Mauro de Souza 5 years ago
parent
commit
e7fa33feb4
2 changed files with 15 additions and 4 deletions
  1. 14 3
      tools/hidl/hidlcomp.cpp
  2. 1 1
      tools/hidl/hidlcomp.h

+ 14 - 3
tools/hidl/hidlcomp.cpp

@@ -1898,7 +1898,7 @@ bool ParamInfo::write_mapinfo_check(int indents, const char* ctxvar)
     return hasOutput;
 }
 
-void ParamInfo::write_esp_marshall(bool isRpc, bool encodeXml, bool checkVer, int indents)
+void ParamInfo::write_esp_marshall(bool isRpc, bool encodeXml, bool checkVer, int indents, bool encodeJson)
 {
     const char *soap_path=getMetaString("soap_path", NULL);
     char *path = (soap_path!=NULL) ? strdup(soap_path) : NULL;
@@ -1969,7 +1969,7 @@ void ParamInfo::write_esp_marshall(bool isRpc, bool encodeXml, bool checkVer, in
             else
             {
                 outf("%s, \"\", %s", encode, prefix);
-                if (getMetaInt("json_inline"))
+                if (getMetaInt("json_inline", !encodeJson))
                     outs(", false");
                 outs(");\n");
             }
@@ -4359,10 +4359,21 @@ void EspMessageInfo::write_esp()
 
         if (hasMapInfo())
             outf("\t\tdouble clientVer = ctx ? ctx->getClientVersion() : -1;\n");
+
+        bool encodeJSON = true;
+        const char * name = getName();
+        unsigned nameLength = strlen(name);
+        if (nameLength >= 2)
+        {
+            const char * nameEnding = &name[nameLength - 2];
+            bool isResponseEx = strcmp(nameEnding, "Ex") == 0;
+            encodeJSON = !(isResponseEx && (stricmp(getParams()->getXmlTag(), "Response") == 0));
+        }
+
         for (pi=getParams();pi!=NULL;pi=pi->next)
         {
             if (!pi->getMetaInt("attribute"))
-                pi->write_esp_marshall(false, encodeXML, true, 2);
+                pi->write_esp_marshall(false, encodeXML, true, 2, encodeJSON);
         }
         outs("\t}\n");
     }

+ 1 - 1
tools/hidl/hidlcomp.h

@@ -443,7 +443,7 @@ public:
     void write_esp_declaration();
     void write_esp_ng_declaration(int pos);
     void write_esp_init(bool &isFirst, bool removeNil);
-    void write_esp_marshall(bool isRpc, bool encodeXml, bool checkVer=false, int indent=1);
+    void write_esp_marshall(bool isRpc, bool encodeXml, bool checkVer=false, int indent=1, bool encodeJson=true);
     void write_esp_unmarshall(const char *rpcvar, bool useBasePath=false, int indents=1);
     void write_esp_unmarshall_properties(const char *propvar, const char *attachvar, int indents=1);
     void write_esp_unmarshall_soapval(const char *var, int indents=1);