The content of HTML deliveries is returned as an XML CDATA node. Sometimes this content itself may contain CDATA elements. Campaign will "escape" such content as follow:
When the SDK tried to convert XML to JSON, it has the following logic:
(1) If a XML element has a unique text child (text or cdata type), it will generate a JSON property starting with the element name prefix with "$". For instance <![CDATA[Hello]]> will be converted to $title: "Hello".
(2) However, if there are multiple children, it will generate a JSON object with a "$" property. For instance: <![CDATA[Hello]]><![CDATA[World]]> will return "title": { "$": "HelloWorld" } and not "$title": "HelloWorld".
In our delivery content example, the /<![CDATA[/ and /]]]><![CDATA[]>/ escaping is a hack which actually splits the content into 2 CDATA elements. So when it's used, the delivery content will be returned as "source": { "$": content } instead of "$source": content.
This PR changes the behavior by changing the rule (2) above as follow: if a XML element has multiple children which are all text or cdata nodes, it will use the "$property" syntax instead of "$" property syntax. For the delivery content example, it means that it will always return "$source": content.
Related Issue
Acrite email editor could not process content containing escape CDATA elements (usually coming from ACS) because the it expects the content to be available in "content.html.$source" property and not "content.html.source.$"
Motivation and Context
All types of content should be returned consistently (i.e. with same syntax) by the SDK
How Has This Been Tested?
New unit tests
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[x] Breaking change (fix or feature that would cause existing functionality to change)
Limited risk of breaking things as we are changing the structure of the returned JSON in some edge cases.
Description
The content of HTML deliveries is returned as an XML CDATA node. Sometimes this content itself may contain CDATA elements. Campaign will "escape" such content as follow:
When the SDK tried to convert XML to JSON, it has the following logic:
In our delivery content example, the /<![CDATA[/ and /]]]><![CDATA[]>/ escaping is a hack which actually splits the content into 2 CDATA elements. So when it's used, the delivery content will be returned as "source": { "$": content } instead of "$source": content.
This PR changes the behavior by changing the rule (2) above as follow: if a XML element has multiple children which are all text or cdata nodes, it will use the "$property" syntax instead of "$" property syntax. For the delivery content example, it means that it will always return "$source": content.
Related Issue
Acrite email editor could not process content containing escape CDATA elements (usually coming from ACS) because the it expects the content to be available in "content.html.$source" property and not "content.html.source.$"
Motivation and Context
All types of content should be returned consistently (i.e. with same syntax) by the SDK
How Has This Been Tested?
New unit tests
Types of changes
Limited risk of breaking things as we are changing the structure of the returned JSON in some edge cases.
Checklist: