Skip to content

Invalid XML2JSON conversion of bitmask with a leading 1 #1025

@mhmarkushuber

Description

@mhmarkushuber

We are using the following XML to JSON conversion in our code bases.

private JSONObject xmlToJson() throws Exception {
        JSONObject jsonObj = null;
        FileReader fr = new FileReader(benchmarkXmlFile); // Reads the XML file (data.xml)
        jsonObj = XML.toJSONObject(fr); // Performs the conversion using org.json.XML
        fr.close();
        return jsonObj;
    }

The XML file contains a bitmask

<ProcessAffinity>
          <Ranks>
            <Rank>0</Rank>
            <Mask>1000000000000000000000000000000000000000000000000000</Mask>
          </Ranks>
</ProcessAffinity>

This bit mask is converted to a floating point number in JSON, only if it has a leading "1" otherwise the conversion is valid:

Image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions