For some reason in one of our processes it was decided that an XML is needed that contains partly json data (I know how this sounds :( ).
I'm struggling to get the json data correctly parsed (or the XML correctly formatted).
The json data is generated via json templater and looks like this:
{
"editOptions": {
"cascadeEditOptions": {
"cascadeStrategy": {
"type": "NoCascadeStrategy",
"enabledTypes": []
}
},
"userProvidedIds": true
}
}
The XML structure should be like this:
<data>
<metadata>
<projectName>SomeProject</projectName>
</metadata>
<action>
<Modification operationId="test_operation_id_1" Id="1" requestBody='
{
"editOptions": {
"cascadeEditOptions": {
"cascadeStrategy": {
"type": "NoCascadeStrategy",
"enabledTypes": []
}
},
"userProvidedIds": true
}
}
'/>
</action>
</data>
The problem is when I provide the json data into the XML templater.
It gives an error on an invalid expression invalid expression: syntax error, unexpected character "{"
So I've tried the following as well:
Create the XML structure via an attribute manager and use it in the xml templater via fme-get-xml-attribute, but then it parses the json terrible:
<data-exchange>
<metadata>
<modelName>TTOM</modelName>
<modelVersion>4_0</modelVersion>
<projectName>GEN_AreaImprovement_Tests</projectName>
</metadata>
<transaction sequenceId="1">
<applyModifications operationId="test_operation_id_1" entityId="153758d6-fbae-4943-9efa-89df952c7126" requestBody="{"editOptions": { "cascadeEditOptions": { "cascadeStrategy": { "type": "NoCascadeStrategy", "enabledTypes": [] } }, "userProvidedIds": true }}"/>
</transaction>
</data-exchange>
When providing it as regular attribute, it has an issue with the XML < /> things:
<data-exchange>
<metadata>
<modelName>TTOM</modelName>
<modelVersion>4_0</modelVersion>
<projectName>GEN_AreaImprovement_Tests</projectName>
</metadata>
<transaction sequenceId="1">
<applyModifications operationId="test_operation_id_1" entityId="153758d6-fbae-4943-9efa-89df952c7126" requestBody='{"editOptions": {
"cascadeEditOptions": {
"cascadeStrategy": {
"type": "NoCascadeStrategy",
"enabledTypes": []
}
},
"userProvidedIds": true
}}'/>
</transaction>
</data-exchange>
Probably I can replace < and > with their correct signs, but it's not a graceful way to work.
Is there another way go generate this in a more graceful way or did I overlook a thing?