Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
translate xml to json, written in haskell.
Haskell
Branch: encoding
Pull request Compare This branch is 28 commits behind master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Text/XML
.gitignore
LICENSE
Main.hs
README.rst
Setup.hs
xml2json.cabal

README.rst

Translate xml to json, and thanks to tagstream-conduit, it can parse malformed xml.

Examples

Simple example

XML

<test "k1"="v1" "k2"="v2">
    aaa
    <p>bbb</p>
    ccc
</test>

JSON

{"test":{"p":"bbb"
        ,"__attributes":{"k2":"v2","k1":"v1"}
        ,"__values":["\n    ccc\n","aaa\n    "]
        }
,"__values":["\n"]
}

Siblings with same name got merged.

XML

<books>
    <book>
        <name>foo</name>
        <author>Jim</author>
    </book>
    <book>
        <name>bar</name>
        <author>Jake</author>
    </book>
</books>

JSON

{"__values":["\n"]
,"books":{"book":[{"author":"Jim"
                  ,"name":"foo"
                  ,"__values":["\n    ","\n        "]
                  }
                 ,{"author":"Jake"
                  ,"name":"bar"
                  ,"__values":["\n    ","\n        "]
                  }
                 ]
         ,"__values":["\n","\n    "]
         }
}
Something went wrong with that request. Please try again.