Json decoder to xml in pipeline returns empty string for nullable fields

t8eo 1 Reputation point

I am using the usual implementation for Json to Xml pipeline (https://learn.microsoft.com/en-us/biztalk/core/create-custom-pipelines-to-process-json-messages) but I face a problem. The fields that are null in the Json, the receive pipeline transforms the field to empty string ''. How can I have the field after the pipeline transformation as null and not as the empty string ''.

For example If I have a nullable datatime field in my schema I take the error:
"The XML Validator failed to validate. The 'StopDate' element is invalid - The value '' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:dateTime' - The string '' is not a valid DateTime value.. ".

I can overcome the problem if I make the fields in the schema type string that can accept the '', but I cannot pass the null value that way.
Any solutions?

Microsoft BizTalk Server
Microsoft BizTalk Server
A family of Microsoft server products that support large-scale implementation management of enterprise application integration processes.
355 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Colin Dijkgraaf 1,346 Reputation points

    A workaround would be that the schema that the JSON payload maps to has it defined as a string, and then you only map it to the canonical or internal schema which has it as a date field if it is not an empty string.

    Another option would be similar the the solution in REST JSON Christmas Puzzle – Work around but to find an empty node and adding xsi:nil="true" e.g. find <StopDate></StopDate> and replace with <StopDate xsi:nil="true"></StopDate>

    1 person found this answer helpful.
    0 comments No comments