Open nichtich opened 5 years ago
@nichtich You seem to be well versed in XML. What would you expect the output of
{
"type": "Polygon",
"coordinates": [
[
[
-122.422003528252475,
37.808480096967251,
0.0
],
[
-122.422003528252475,
37.808480096967251,
0.0
]
]
]
}
to be in XML?
I created another issue for this and related examples. I first thought about not supporting nested arrays at all but the current solution with <item>
as default XML element name also makes sense, it only needs to be configurable (--xml-item NAME
)?
Cool thanks. The issue with being able to specify that is it would be global, which is probably fine? I.e. in a 3D array like that, there wouldn't be a way to target a specific level of the nested array. The way around this is using a transformation to give keys to those values, as it'll use the key name if there is one.
The issue with being able to specify that is it would be global, which is probably fine?
Yes. Alternatives I can think of is to ignore nested array elements, flatten nested arrays or to raise an error, but your approach looks more useful. The only argument against is more difficult XML reading to ensure round-tripping conversion (XML->JSON->XML->JSON should be equal to XML->JSON).
I worked a lot with XML and created a similar JSON/XML mapping tool (see Catmandu::XML and other Catmandu modules) but there is no silver bullet.
Yea I can't imagine being able to convert formats and have everything be 1:1 conversions. Are always going to be some edge cases IMO. It helps that you can use jq
to transform the JSON to get it into a better structure for serialization to XML.
The current implementation of Crystal's JSON::PullParser
allows the consumption of only 1 JSON document at a time. I don't think this would be trivial to do. I'll keep this open and will accept PRs if someone wants to tackle it.
Possibly can revisit it in the future.
Expected:
Sure this makes more sense with #14. YAML on the other hand supports multiple documents concatenated.
sorry for coming up with all of these edge cases, I'm actually looking for them :see_no_evil: