microsoft / XmlNotepad

XML Notepad provides a simple intuitive User Interface for browsing and editing XML documents.
https://microsoft.github.io/XmlNotepad/
MIT License
989 stars 207 forks source link

Feature Request - Ability to open JSON files that begin with an array #389

Open stevebow opened 5 months ago

stevebow commented 5 months ago

When trying to open a JSON file that begins with an array (character "["), XmlNotepad (2.9.0.10) displays the following error:

XmlNodeConverter can only convert JSON that begins with an object. Path '', line 1, postition 1.

Would it be possible for the XmlNodeConverter to convert JSON files that begin with an array please? Example JSON file attached.

Also, should the Path single quotes in the error message contain anything?

Thanks.

70.zip

lovettchris commented 5 months ago

We could, but XML can only have one root element, so we'd have to invent the name of that root container. Or we take only the first element in the array? Which is your preference? If you want to invent a root element name, what name would you choose?

stevebow commented 5 months ago

I do think all elements ought to be imported, if that is what you meant. As for a root container name? Perhaps simply the filename stem? The user could change it after import if they prefer something else. Sorry, I'm not terribly imaginative when it comes to names. :^/