Author |
Message
|
ghoshly |
Posted: Fri Mar 01, 2019 5:17 pm Post subject: XML to JSON conversion - Empty field |
|
|
Partisan
Joined: 10 Jan 2008 Posts: 333
|
Hello,
I am using IIB v10.0.0.10 and converting an XML input to JSON format to call external service. In case of an empty field (<EndDate></EndDate>), by default JSON serializer is creating an empty object with {} notation as "EndDate":{}. However, the end system is failing to understand / accept the format and expecting "" in place.
Is there a way / configuration in IIB, that I can use to generate empty JSON field as "EndDate": ""
Thanks in advance. |
|
Back to top |
|
 |
timber |
Posted: Mon Mar 04, 2019 2:31 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
There is no way to do this in the JSON output.
However, you may be able to add a default value to your XML Schema for EndDate, so that an empty string gets parsed as "EndDate". Just bear in mind that "EndDate" is not a valid XML Schema date, so you will need to model it as xs:string. |
|
Back to top |
|
 |
ghoshly |
Posted: Mon Mar 04, 2019 7:28 am Post subject: XML to JSON conversion - Empty field |
|
|
Partisan
Joined: 10 Jan 2008 Posts: 333
|
Thanks Kimbert for your reply. Source side application is not a problem here and the issue is with Target system which is expecting "" only to perform certain tasks. |
|
Back to top |
|
 |
timber |
Posted: Mon Mar 04, 2019 9:29 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
Source side application is not a problem here and the issue is with Target system |
Yes, I got that. But your message flow must be parsing the XML, so it can apply default values while doing so. You should be able to automatically convert an empty EndDate tag into a tag with a default value. |
|
Back to top |
|
 |
ghoshly |
Posted: Thu Mar 07, 2019 1:20 pm Post subject: Handling with NULL value. |
|
|
Partisan
Joined: 10 Jan 2008 Posts: 333
|
Luckily, the end system accepted NULL VALUE for the field and I am handling it that way. |
|
Back to top |
|
 |
akashnambiar95 |
Posted: Thu Mar 07, 2019 10:34 pm Post subject: |
|
|
Newbie
Joined: 07 Mar 2019 Posts: 1
|
Did you try using the coalesce function? I think that'd help |
|
Back to top |
|
 |
|