xml2json icon indicating copy to clipboard operation
xml2json copied to clipboard

Incorrect data encoded in json when numeric support is enabled

Open minhaajk opened this issue 3 years ago • 2 comments

Hello,

While using this library, I found a bug which I am reporting as below

Value like 99921-58-10-7 is encoded as 99921 in json

Input XML

<?xml version="1.0"?>
<Book>
	<name>Sample Book Name</name>
	<author>New Author</author>
	<ISBN>99921-58-10-7</ISBN>
	<price>102.50</price>
</Book>

Output JSON

{
    "Book": {
        "name": "Sample Book Name",
        "author": "New Author",
        "ISBN": 99921,
        "price": 102.5
    }
}

minhaajk avatar Sep 10 '20 13:09 minhaajk

<?xml version="1.0"?>
<Book>
	<name>Sample Book Name</name>
	<author>New Author</author>
	<ISBN>99921-58-10-7</ISBN>
	<price>102.50</price>
</Book>

may be converted to the

{
  "Book": {
    "name": "Sample Book Name",
    "author": "New Author",
    "ISBN": "99921-58-10-7",
    "price": "102.50"
  }
}

javadev avatar Mar 29 '21 09:03 javadev

Hello @javadev , the issue is when we enable numeric support and try to convert the xml.

Kindly change it in xml2json.hpp (line 32) and try again

static const bool xml2json_numeric_support = true;

minhaajk avatar Jun 02 '21 07:06 minhaajk