Ti trovi qui:
XML e JSON nei data mapper Omnistudio
Oltre al JSON, i Data Mappers possono avere input e output XML. Il formato XML in Data Mappers è una struttura di tipo JSON simile a un valore chiave non ordinato.
Per specificare l'ordine in cui vengono serializzati gli elementi dell'output XML, compilare il riquadro Output XML previsto con una struttura XML composta nell'ordine desiderato.
Questo esempio confronta le strutture equivalenti in JSON e XML.
JSON
{
"Root": {
"#text": "rootValue",
"@attribute1": "attVal1",
"#ns": "http://namespace1",
"#ns#a": "http://namespace2",
"Child": [{
"@attribute2": "attval2"
},
{
"#text": "childValue"
}
]
}
}
XML
<Root attribute1="attVal1" xmlns="http://namespace1" xmlns:a="http://namespace2">
rootValue
<Child attribute2="attval2"></Child>
<Child>childValue</Child>
</Root>
Mappatori di dati che trasformano XML in JSON utilizzando queste convenzioni per gestire le differenze tra i formati.
- I valori di un nodo XML di input vengono tradotti in JSON di output con il
#textchiave. - XML:
<Root>rootValue</Root> - JSON:
{ "Root": { "#text": "rootValue" } } - I valori di un nodo XML di input vengono tradotti in JSON di output con una chiave preceduta dal segno at (
@). - XML:
<Root attribute1="attVal1"></Root> - JSON:
{ "Root": { "@attribute1": "attVal1" } } - Gli spazi dei nomi in un nodo XML di input sono preceduti da
#nsnel JSON di output. - XML:
<Root xmlns="http://namespace1" xmlns:a="http://namespace2"> </Root> - JSON:
{ "Root": { "#ns":"http://namespace1", "#ns#a":"http://namespace2, } } - I due punti, che sono caratteri riservati nelle mappature di Data Mapper, sono sostituiti da
#. - XML:
<Root:Data>data</Root:Data> - JSON:
{ "Root#Data": { "#text":"data", } }
