none
Logic App -- XML to JSON Object Array null RRS feed

  • Question

  • Hi everyone,

    I have a question, I am converting a  XML soap message to JSON with the following Schema.

    the convert is  @json(xml(body('Haal_posities_op')))

    is also tried with xpath but i keeps telling me on the positions it is an empty array. But when i check the raw result, the array is filled.

    i remove somed inner data bat te soap message looks live the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soapenv:Body>
            <getPositionsResponse>
                <result>
                    <message xsi:nil="true"/>
                    <positions>
                        <AAP24 xsi:nil="true"/>
                        <salary xsi:nil="true"/>
                        <salaryLevel xsi:nil="true"/>
                        <salaryMaximum xsi:nil="true"/>
                        <salaryMinimum xsi:nil="true"/>
                        <salaryPeriod>Month</salaryPeriod>
                        <startDate>2018-10-25</startDate>
                        <subTitle xsi:nil="true"/>
                    </positions>
                   
                </result>
            </getPositionsResponse>
        </soapenv:Body>
    </soapenv:Envelope>

    {
      "type": "object",
      "properties": {
        "positions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "AAP24": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "accountDescription": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "accountExternalId": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "accountName": {
                "type": "string"
              },
              "applicationUrl": {
                "type": "string"
              },
              "companyInformation": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "companyLocation": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "compensationBenefits": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "contactInfo": {
                "type": "string"
              },
              "contractType": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "country": {
                "type": "string"
              },
              "custom1": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "custom2": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "custom3": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "custom4": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "custom5": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "customFields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "key",
                    "value"
                  ]
                }
              },
              "customRich1": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "customRich2": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "durationNumberOfUnit": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "durationProlongationOptional": {
                "type": "string"
              },
              "durationUnit": {
                "type": "string"
              },
              "endDate": {
                "type": "string"
              },
              "externalId": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "featuredJob": {
                "type": "string"
              },
              "functionExternalId": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "hiringManager": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "externalId": {
                    "type": "object",
                    "properties": {
                      "@xsi:nil": {
                        "type": "string"
                      }
                    }
                  },
                  "firstName": {
                    "type": "string"
                  },
                  "gender": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "lastName": {
                    "type": "string"
                  },
                  "logoUrl": {
                    "type": "object",
                    "properties": {
                      "@xsi:nil": {
                        "type": "string"
                      }
                    }
                  },
                  "mobilePhone": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "object",
                    "properties": {
                      "@xsi:nil": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "hoursPerWeek": {
                "type": "string"
              },
              "hrAdvisor": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "externalId": {
                    "type": "object",
                    "properties": {
                      "@xsi:nil": {
                        "type": "string"
                      }
                    }
                  },
                  "firstName": {
                    "type": "string"
                  },
                  "gender": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "lastName": {
                    "type": "string"
                  },
                  "logoUrl": {
                    "type": "object",
                    "properties": {
                      "@xsi:nil": {
                        "type": "string"
                      }
                    }
                  },
                  "mobilePhone": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  }
                }
              },
              "id": {
                "type": "string"
              },
              "jobDescription": {
                "type": "string"
              },
              "jobEndDate": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "jobLocationZipCode": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "jobRequirements": {
                "type": "string"
              },
              "jobStartDate": {
                "type": "string"
              },
              "jobType": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "location": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "onlineApplicationAllowed": {
                "type": "string"
              },
              "positionUrl": {
                "type": "string"
              },
              "questionUrl": {
                "type": "string"
              },
              "recruiter": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "externalId": {
                    "type": "object",
                    "properties": {
                      "@xsi:nil": {
                        "type": "string"
                      }
                    }
                  },
                  "firstName": {
                    "type": "string"
                  },
                  "gender": {
                    "type": "object",
                    "properties": {
                      "@xsi:nil": {
                        "type": "string"
                      }
                    }
                  },
                  "id": {
                    "type": "string"
                  },
                  "lastName": {
                    "type": "string"
                  },
                  "logoUrl": {
                    "type": "object",
                    "properties": {
                      "@xsi:nil": {
                        "type": "string"
                      }
                    }
                  },
                  "mobilePhone": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  }
                }
              },
              "salary": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "salaryLevel": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "salaryMaximum": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "salaryMinimum": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              },
              "salaryPeriod": {
                "type": "string"
              },
              "startDate": {
                "type": "string"
              },
              "subTitle": {
                "type": "object",
                "properties": {
                  "@xsi:nil": {
                    "type": "string"
                  }
                }
              }
            },
            "required": [
              "AAP24",
              "accountDescription",
              "accountExternalId",
              "accountName",
              "applicationUrl",
              "companyInformation",
              "companyLocation",
              "compensationBenefits",
              "contactInfo",
              "contractType",
              "country",
              "custom1",
              "custom2",
              "custom3",
              "custom4",
              "custom5",
              "customFields",
              "customRich1",
              "customRich2",
              "durationNumberOfUnit",
              "durationProlongationOptional",
              "durationUnit",
              "endDate",
              "externalId",
              "featuredJob",
              "functionExternalId",
              "hiringManager",
              "hoursPerWeek",
              "hrAdvisor",
              "id",
              "jobDescription",
              "jobEndDate",
              "jobLocationZipCode",
              "jobRequirements",
              "jobStartDate",
              "jobType",
              "location",
              "name",
              "onlineApplicationAllowed",
              "positionUrl",
              "questionUrl",
              "recruiter",
              "salary",
              "salaryLevel",
              "salaryMaximum",
              "salaryMinimum",
              "salaryPeriod",
              "startDate",
              "subTitle"
            ]
          }
        }
      }
    }

    but each time i try to 

    Thursday, October 25, 2018 8:21 PM

All replies

  • Hi Vincent

    What is the encoding set to when you attempt to do this conversion? Since you've mentioned that the XML data is of a SOAP message, I'm assuming that you already have "Content-type" header set to "application/xml", in which case, you can just do: 

    @{json(xml(triggerBody()))}
    This works for me when I plug in the sample XML data set that you've shared above and am successfully converting the this data to a valid JSON. Hope this helps, let me know if there are further details and I'd be happy to weight in :)
    Monday, October 29, 2018 9:04 PM
    Moderator