-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Labels
Description
We have following FLUX:
"testArray.json"
| open-file
| as-records
| decode-json
| morph("all.xml")
| encode-json(prettyPrinting="true")
| write("stdout");
the morph is:
<?xml version="1.0" encoding="UTF-8"?>
<metamorph xmlns="http://www.culturegraph.org/metamorph" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1">
<rules>
<data source="_elseNested"/>
</rules>
</metamorph>
The incoming JSON is e.g.:
{
"author": [
{
"@type": "Person",
"name": "Katja Königstein-Lüdersdorff"
},
{
"@type": "Person",
"name": "Corinna Peters"
},
{
"@type": "Person",
"name": "Oleg Tjulenev"
},
{
"@type": "Person",
"name": "Claudia Vogeler"
}
]
}It results in:
{
"1" : {
"@type" : "Person",
"name" : "Katja Königstein-Lüdersdorff"
},
"2" : {
"@type" : "Person",
"name" : "Corinna Peters"
},
"3" : {
"@type" : "Person",
"name" : "Oleg Tjulenev"
},
"4" : {
"@type" : "Person",
"name" : "Claudia Vogeler"
}
}Without the morph it works:
With flux:
"testArray.json"
| open-file
| as-records
| decode-json
| encode-json(prettyPrinting="true")
| write("stdout");
Result is:
{
"author" : [ {
"@type" : "Person",
"name" : "Katja Königstein-Lüdersdorff"
}, {
"@type" : "Person",
"name" : "Corinna Peters"
}, {
"@type" : "Person",
"name" : "Oleg Tjulenev"
}, {
"@type" : "Person",
"name" : "Claudia Vogeler"
} ]
}
The fault is due to _elseNested. With "_elseFlattened" we receive following result:
{
"author[].1.@type" : "Person",
"author[].1.name" : "Katja Königstein-Lüdersdorff",
"author[].2.@type" : "Person",
"author[].2.name" : "Corinna Peters",
"author[].3.@type" : "Person",
"author[].3.name" : "Oleg Tjulenev",
"author[].4.@type" : "Person",
"author[].4.name" : "Claudia Vogeler"
}I assume there is a conflict with the [] as the sign for an array in combination with the nested transformation.