Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect data encoded in json when numeric support is enabled #17

Open
minhaajk opened this issue Sep 10, 2020 · 2 comments
Open

Incorrect data encoded in json when numeric support is enabled #17

minhaajk opened this issue Sep 10, 2020 · 2 comments

Comments

@minhaajk
Copy link

minhaajk commented Sep 10, 2020

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
    }
}
@javadev
Copy link

javadev commented Mar 29, 2021

<?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"
  }
}

@minhaajk
Copy link
Author

minhaajk commented Jun 2, 2021

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants