I wish there were a simple answer and a solution to your problem. First, your assumption on XML and JSON are mutually exclusive is WRONG.
XML doesn’t have a null definition out of the box. In order to define a null in an XML document, you need to add property ‘nill’ to the tag and set its value to true as you can see in reamon’s example, but once you add that value to your tag then your object is no longer a simple type. You cannot map the value of a complex type to another simple type(actually you can but once you do it you will have a complex type, not a simple type hence it won’t be visible in designer unless you debug) and since the types won’t match you won’t see that complex type in your response.
If you inspect your nullable field from designer, you will see
supposed_simple_type
|- @nill
|- data
in your supposed simple string type object. In order to copy the value of this field you need to map the data field, but in order to do it your document must be generated properly (preferably from an XSD file) and it will still not be set to null even when your nill atribute is true.
As reamon said, if you include business logic/requirement for this task, we may recommend a better solution. Right now you are experiencing an xy problem.
As a starting point, assume everything should be a document in Integration Server. So If you want to generate an XML or JSON string, you need to have a document first. This document can be generated from a JSON or XML string as well as other types like flat file. But this doesn’t mean that you will get the same document from the JSON and XML object as long as you generate them from the same initial object.
If a field in a document has a null value, the string object you create from that document will have different values according to the type you are converting that in to. For JSON strings you will have a proper null values, for xml strings its highly likely that you won’t have nulls but you will have empty strings in your XML string after you convert. This is because by definition XML doesn’t have a null and it does not support it. Both of the solutions are workaround (one of them is nill attribute, the other is empty tag like </nullableField>
.
tl;dr
XML object’s don’t support null values by definition hence we don’t have a way to interpret null values in XML files. If you have issues with null values when dealing with XML files, it’s so much more easier to not use them at all then implementing a workaround.
Try not to convert JSON to XML and vice versa. If you need to generate both as output, do it from the document(not from the generic one, define one if not defined), not from the string itself.