Am working on a POC where I have to invoke a Rest Api, collect the response and do futher processing on it. So to accept JSON data coming in response, I created a custom pipeline having JSON decoder at decode stage. After deploying the project and configuring it, dropped the test instance at receive location and watching for output in OUT folder(configured to archive API response).
As no output was generated - means some error was encountered, visited event log and found below error:
It was my bad, missed to set couple of properties which are required by JSON decoder to convert JSON message in corresponding XML message i.e. Root Node Name and Namespace.
Above error is in situation where you do not specify Root Node Name and Namespace both or if only Namespace is set.
Out of curiosity wanted to check what JSON decoder says if I set Root Node Name only and leave Namespace as Blank - It says, I want it to build XML message for you ;)
When using JSON decoder it is mandatory to provide this two properties. It is because the Key is converted into element and Value as element value.
e.g.,
JSON Message:
{
"company": "Maruti",
"name": "Swift",
"price": 800000
}
Corresponding XML:
<company>Maruti</company>
<name>Swift</name>
<price>800000</price>
But a valid XML has a Root Node, thus that needs to be provided explicitly to JSON decoder to attach the converted XML structure under Root Node
As no output was generated - means some error was encountered, visited event log and found below error:
Why this happened
It was my bad, missed to set couple of properties which are required by JSON decoder to convert JSON message in corresponding XML message i.e. Root Node Name and Namespace.
Above error is in situation where you do not specify Root Node Name and Namespace both or if only Namespace is set.
Out of curiosity wanted to check what JSON decoder says if I set Root Node Name only and leave Namespace as Blank - It says, I want it to build XML message for you ;)
What to do
When using JSON decoder it is mandatory to provide this two properties. It is because the Key is converted into element and Value as element value.
e.g.,
JSON Message:
{
"company": "Maruti",
"name": "Swift",
"price": 800000
}
Corresponding XML:
<company>Maruti</company>
<name>Swift</name>
<price>800000</price>
But a valid XML has a Root Node, thus that needs to be provided explicitly to JSON decoder to attach the converted XML structure under Root Node
If you have questions or suggestions, feel free to do in comments section below !!!
Do share if you find this helpful .......
Knowledge Sharing is Caring !!!!!!