StripLevels in XML to JSON policy not working for me

Not applicable

I want to convert xml payload to json payload as a response, I am using StripLevels option to trim the root element in the payload, but it is not working for me.

Here is my config

<XMLToJSON async="false" continueOnError="false" enabled="true" name="ConvertXMLToJSON">
    <DisplayName>ConvertXMLToJSON</DisplayName>
    <Properties/>
    <Options>
        <RecognizeNumber>true</RecognizeNumber>
        <RecognizeBoolean>true</RecognizeBoolean>
        <RecognizeNull>true</RecognizeNull>
        <StripLevels>3</StripLevels>
    </Options>
    <OutputVariable>response</OutputVariable>
    <Source>response</Source>
</XMLToJSON>

I still got json from the root element.(I confirmed that cache not turned on from the trace)

Who could tell me where is the problem.

Solved Solved
1 5 566
1 ACCEPTED SOLUTION

g-gagan1000
Participant III
@Zheng Yang

I tried to strip levels using XmlToJson policy and I am successfully able to do that.

There can be one exception that you have multiple children under the root, and hence the strip levels element will not be able to strip the levels from your payload and you will get the same result. This scenario is explained clearly in the documentation here .

Can you analyze your response from the backend or share in the comment(if possible).

Hope this helps.

View solution in original post

5 REPLIES 5

g-gagan1000
Participant III
@Zheng Yang

I tried to strip levels using XmlToJson policy and I am successfully able to do that.

There can be one exception that you have multiple children under the root, and hence the strip levels element will not be able to strip the levels from your payload and you will get the same result. This scenario is explained clearly in the documentation here .

Can you analyze your response from the backend or share in the comment(if possible).

Hope this helps.

Yeah, you are right.I just realised that there are multiple elements in the root level.

I think in order to get the payload in particular strip level, I should remove useless elements from the payload and convert to json with strip levels after that.

Hi @Zheng Yang - would it be possible to share the xml payload being passed and the output you are getting with the above policy. Also share the expected JSON output so we could provide any recommendations

Hi Sai Saran Vaidyanathan

I think Gagandeep Singh's reply answered my question. there is a sample in the doucment.

Thanks.

sjm2000
Participant V

Keep in mind please if edge is giving tag error for striplevels , while deploying the proxy, you might require an update to your edge to latest version

Thanks