Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion fails when JSON key name is not a legal XML element name #10

Closed
dwcramer opened this issue Nov 11, 2013 · 3 comments
Closed

Comments

@dwcramer
Copy link

Given the input JSON:

{
   "^.{0,256}$": "foo"
}

I receive the following error:

dcramer@anatine ~/Desktop/json2plainparams/json_schema (master)
$ ./json2xml.py test.json 
Debug mode is on. Events are logged at: dicttoxml.log
test.json
Traceback (most recent call last):
  File "./json2xml.py", line 18, in <module>
    dom = parseString(xml)
  File "/usr/lib/python2.7/xml/dom/minidom.py", line 1931, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 46

Due to the fact that <^.{0,256}$>foo</^.{0,256}$> would not be well-formed xml.

I would suggest an xml format like foo to avoid this problem.

@quandyfactory
Copy link
Owner

Thanks for bringing this to my attention. I should be able to commit a fix in the next day or so.

@dwcramer
Copy link
Author

Thanks! Btw., in my original message I see that my suggested output was munged because I hadn't escaped the angle brackets. Here's what I was trying to say: "I would suggest an xml format like <key name="^.{0,256}$">foo</key> to avoid this problem. "

@quandyfactory
Copy link
Owner

Sorry it took a lot longer than I expected, but I finally got around to fixing this issue. It's addressed in version 1.3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants