Skip to content

joepjoosten/xslt-json-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

xslt-json-parser

XSLT 2.0 JSON parser for the json.org dialect.

Example usage:

The XML file

<?xml version="1.0" encoding="utf-8"?>
<data>{"myArray": [null, true, false, "A String", 1234.1234], "Another pair": true}</data>

The XSL file

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:j="urn:xslt-json-parser:json-parser">
    
    <xsl:output indent="yes"/>
    
    <xsl:import href="json-parser.xsl"/>
    
    <xsl:template match="/">
        <xsl:copy-of select="j:parse-json(data)"/>
    </xsl:template>
</xsl:stylesheet>

The result:

<?xml version="1.0" encoding="utf-8"?>
<object>
    <pair name="myArray">
        <array>
            <null/>
            <boolean>true</boolean>
            <boolean>false</boolean>
            <string>A String</string>
            <number>1234.1234</number>
        </array>
    </pair>
    <pair name="Another pair">
        <boolean>true</boolean>
    </pair>
</object>

About

XSLT 2.0 JSON parser for the json.org dialect

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages