This task takes an object as an input, which is the converted to XML according to the following rules and parameters.

Version 2 (2.0.0.0) throws an exception, if the XML parsed from JSON is not actually valid (eg, JSON keys are numeric). This version also makes it possible to append numeric keys with a specific string.

Note: the task uses a recursive helper function to look through the JSON keys. Due to recursiveness, the task might blow up the stack with large inputs. If you suspect that your input contains many nested arrays or braces-enclosed data, be sure to test the task thoroughly.

Input Parameters

  • Input
    • The object that is converted to JSON. Input can be given in the following formats:
      • JSON as a C# String
      • CSV as a C# String
      • FixedLength as a C# String
  • CSVSeparator
    • If your input is CSV, enter the CSV separator here as a string, for example ,
    • Otherwise leave empty
  • XMLRootElementName
    • The name of the root element inside which the generated XML is inserted.
  • FLColumnLengths
    • If your input is fixed length, enter the all of the column lengths as an array of Integers
    • Otherwise leave empty
  • JsonAppendNumericKeysWith
    • If numeric JSON keys need to be changed before conversion to XML, enter the string to be appended to the keys here.
    • Otherwise leave empty.
  • InputHasHeaderRow
    • Boolean value indicating if your CSV or FixedLength file should have a header row
    • By default false
  • TrimOuputColumns
    • Boolean value indicating if the values of your CSV or fixed length input should be trimmed, for example a value of "Value 123 " would result in a XML value of "Value 123"
    • By default false

Output Result

  • String
    • A string containing the converted XML

Example Usage

For example calling this task, with JsonAppendNumericKeysWith set to "foo" and with the following input:

{
	"expand": "schema,names",
	"startAt": 0,
	"maxResults": 1000,
	"total": 36,
	"issues": [{
			"expand": "operations,versionedRepresentations,editmeta,changelog,transitions,renderedFields",
			"id": "204588",
			"self": "https://teams.hiq.fi/jira/rest/api/2/issue/xxxxx",
			"key": "YYY-6",
			"fields": {
				"assignee": {
					"self": "https://teams.hiq.fi/jira/rest/api/2/user?username=user1",
					"name": "User1",
					"key": "user1",
					"emailAddress": "user1@hiq.fi",
					"avatarUrls": {
						"48x48": "https://teams.hiq.fi/jira/secure/useravatar",
						"24x24": "https://teams.hiq.fi/jira/secure/useravatar?size=small",
						"16x16": "https://teams.hiq.fi/jira/secure/useravatar?size=xsmall",
						"32x32": "https://teams.hiq.fi/jira/secure/useravatar?size=medium"
					},
					"displayName": "User1",
					"active": true,
					"timeZone": "Europe/Helsinki"
				}
			}
		}
	]
}

Will produce the following XML document:

<root>
	<expand>schema,names</expand>
	<startAt>0</startAt>
	<maxResults>1000</maxResults>
	<total>36</total>
	<issues>
		<expand>operations,versionedRepresentations,editmeta,changelog,transitions,renderedFields</expand>
		<id>204588</id>
		<self>https://teams.hiq.fi/jira/rest/api/2/issue/xxxxx</self>
		<key>YYY-6</key>
		<fields>
			<assignee>
				<self>https://teams.hiq.fi/jira/rest/api/2/user?username=user1</self>
				<name>User1</name>
				<key>user1</key>
				<emailAddress>user1@hiq.fi</emailAddress>
				<avatarUrls>
					<foo48x48>https://teams.hiq.fi/jira/secure/useravatar</foo48x48>
					<foo24x24>https://teams.hiq.fi/jira/secure/useravatar?size=small</foo24x24>
					<foo16x16>https://teams.hiq.fi/jira/secure/useravatar?size=xsmall</foo16x16>
					<foo32x32>https://teams.hiq.fi/jira/secure/useravatar?size=medium</foo32x32>
				</avatarUrls>
				<displayName>User1</displayName>
				<active>true</active>
				<timeZone>Europe/Helsinki</timeZone>
			</assignee>
		</fields>
	</issues>
</root>

NB. The array structure of "issues" is not preserved in this transformation. This can be dealt with XSL transform, however.

Chek also FRENDS.Common.ConvertToXML_v2 for converting the numeric fields back to original state.