Skip to content

add support for parsing JSON #15

Closed
@pawelmhm

Description

@pawelmhm

Sometimes I'm dealing with deeply nested JSON and I'd like to parse it with xpaths. I know I can use JMESPATH but I dont like JMESPATH syntax, I'm used to xpaths. Also seems like some features of xpaths are not supported by Jmespath, e.g. I can't do recursive traversal, so I can't write //mynode/text() in Jmes I have to do root.foo.bar[].foo2.bar2.product.mynode.

It seems like JSON is currently not supported by js2xml, e.g. something like this:

import js2xml
import json

alfa = json.dumps({"aa": "bb"})
print(alfa)
parsed = js2xml.parse(alfa)
print(parsed.pretty_print())

fails.

Is there some way to add support for JSON parser to js2xml? This would probably require conversion from Python dictionary to xml, seems like there are packages that do this https://github.com/delfick/python-dict2xml so maybe we could learn something from them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions