Open VeryLazyBoy opened 6 years ago
@VeryLazyBoy this is an interesting task, because there is no real mapping of xml to json, the json would likely not come out looking like you think it should. Can you provide an example xml and the json you'd want it to generate?
Currently a json file can be converted to xml like the following:
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": [
"GML",
"XML"
]
},
"GlossSee": "markup"
}
}
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<root>
<glossary>
<title value="example glossary"/>
<GlossDiv>
<title value="S"/>
<GlossList>
<GlossEntry>
<GlossDef>
<para value="A meta-markup language, used to create markup languages such as DocBook."/>
<GlossSeeAlso>
<items>
<item value="GML"/>
<item value="XML"/>
</items>
</GlossSeeAlso>
</GlossDef>
<GlossSee value="markup"/>
<Abbrev value="ISO 8879:1986"/>
<GlossTerm value="Standard Generalized Markup Language"/>
<SortAs value="SGML"/>
<ID value="SGML"/>
<Acronym value="SGML"/>
</GlossEntry>
</GlossList>
</GlossDiv>
</glossary>
</root>
It's great to just have an inversion of current json 2 xml feature.
I see, this might be possible. I will look into it.
@VeryLazyBoy I am not sure I can support a perfect 1 to 1 mapping like this easily, because XML can have many attributes, it would be hard to determine the exact format a user wants.
Turning xml2json like this, the above xml would generate the following JSON
{
"root": {
"glossary": {
"title": {
"@value": "example glossary"
},
"GlossDiv": {
"title": {
"@value": "S"
},
"GlossList": {
"GlossEntry": {
"GlossDef": {
"para": {
"@value": "A meta-markup language, used to create markup languages such as DocBook."
},
"GlossSeeAlso": {
"items": {
"item": [
{
"@value": "GML",
},
{
"@value": "XML"
}
]
}
}
},
"GlossSee": {
"@value": "markup"
},
"Abbrev": {
"@value": "ISO 8879:1986"
},
"GlossTerm": {
"@value": "Standard Generalized Markup Language"
},
"SortAs": {
"@value": "SGML"
},
"ID": {
"@value": "SGML"
},
"Acronym": {
"@value": "SGML"
}
}
}
}
}
}
}```
Yes, I got your point. It is not an easy task. And it seems there is no convention of doing this task. As far as I am considered, this feature is no longer a high priority. You may feel free to close this issue.
Yes, I got your point. It is not an easy task. And it seems there is no convention of doing this task. As far as I am considered, this feature is no longer a high priority. You may feel free to close this issue.
Yeah, it is just because we of xml's flexibility. If we know that it would also because "value" then it would work. Sorry about that :(
Current features are very nice to use and it would be nicer if xml 2 json is supported too.