Project

Profile

Help

xml-to-json omits comma for null map inside map

Added by Greg Knittl about 8 years ago

This appears similar but not identical to issue 2692. Saxon HE 9.7.0.4 on Ubuntu 12.04

command line output: (edited to add newlines and comments)

java net.sansform -it:main testjson.xsl {"hidden": false,"attributes": {},"index": 11} - input string - output of json-to-xml which looks ok false 11 {"hidden":false,"attributes":{}"index":11} - output of xml-to-json which is missing the comma after "attributes":

spreadsheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:f="local-functions.uri" exclude-result-prefixes="xs f" version="3.0">

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:template name="main" > <xsl:variable name="test" as="xs:string">{"hidden": false,"attributes": {},"index": 11}</xsl:variable> <xsl:value-of select="$test"/> <xsl:sequence select="json-to-xml($test)"/> <xsl:value-of select="xml-to-json(json-to-xml($test))"/> </xsl:template> </xsl:stylesheet>


Replies (2)

RE: xml-to-json omits comma for null map inside map - Added by Greg Knittl about 8 years ago

comma is still missing after adding map{'indent':true()} as second argument to xml-to-json. The indenting for null maps in a map also looks incorrect:

        "hidden" : false,
        "attributes" : 
        {  }"index" : 11,

i.e. the null map for attributes shows on the same line as "index"

RE: xml-to-json omits comma for null map inside map - Added by Debbie Lockett about 8 years ago

Thanks for letting us know. This is in fact the same bug as https://saxonica.plan.io/issues/2692 - the patch fixes the problem for empty arrays or maps inside arrays or maps. Further tests have been added to the XSLT 3.0 test suite to cover this last case.

    (1-2/2)

    Please register to reply