ldn-softdev / jtm

HTML/XML to JSON converter
MIT License
45 stars 5 forks source link

Case of a valid JSON output but not totally usable #2

Closed zouhair closed 4 years ago

zouhair commented 4 years ago

This is a link to an xml feed of a youtube channel, so every id is an uploaded video to that channel

"https://www.youtube.com/feeds/videos.xml?channel_id=UCEOXxzW2vU0P-0THehuIIeg"

The output from https://dataconverter.curiousconcept.com/ is https://gist.github.com/zouhair/7086d8aff06359ddcaa2a2a17dc538f3

The output of jtm is https://gist.github.com/zouhair/400267574fdb75e467740a16df4a743d

As you can see the online converter manages to cleanly put every video item in its own tree, while jtm kinda crams everything together while still keeping the json valid.

I won't call this an issue per se but a look at it may be helpful

Thanks again for the work you put on this

ldn-softdev commented 4 years ago

Thanks for contacting me, zouhair

I don't see where jtm "crams everything together" - there each video item is still under own tree (just with more verbose syntax). The conversion spec from XML to JSON in jtm is definitely different than the online converter's, but that's because there's a virtually unlimited number of ways to convert XML to JSON. I developed my conversion spec for jtm so that it could be reversed - i.e. once converted to JSON so it could be converted back to the original format.

Also, after reinstating XML back from JSON - the XML schema of the documents is the same (effectively they are identical XML documents). Which kinda proves that JSON version has the same nestedness of elements as per XML schema (otherwise this wouldn't be a case)

ldn-softdev commented 4 years ago

btw, if you're talking that the JSON is not really readable after conversion (unlike with the online converter) - then it's just a matter of using a good view. E.g. if you use my JSON processing utility jtc and display the same JSON using -tc options - you'll see that it becomes much easier to read it then