Closed vksinghbhu2 closed 11 months ago
I'm unable to replicate this issue, using Visual Studio 2022 (v143) and ISO C++20 Standard (/std:c++20) on Windows 11. In my tests, your example gives the expected results. I tried both reading from the file jsoncons_examples\output\booklist2.json
, and copying and pasting your JSON into a string, and reading from that.
Could you try your test again, but reading from a string, i.e., using
std::string data = R"(
[
{
"author": "Haruki Murakami",
"category": "Fiction",
"date": "2006-01-03",
"isbn": "1400079276",
"price": 13.45,
"title": "Kafka on the Shore"
},
{
"author": "Charles Bukowski",
"category": "Fiction",
"date": "2004-07-08",
"isbn": "1852272007",
"price": 22.48,
"ratings": {
"*****": 4
},
"title": "Pulp"
},
{
"author": "Haruki Murakami",
"category": "Fiction",
"date": "2002-04-09",
"isbn": "037571894X",
"price": 9.01,
"title": "A Wild Sheep Chase: A Novel"
},
{
"author": "George Crile",
"category": "History",
"date": "2007-11-06",
"isbn": "0802143415",
"price": 10.5,
"title": "Charlie Wilson's War"
}
])";
std::istringstream is(data);
Issue is resolved. Thanks.
I have compiled jsoncons library in C++20. I see integer/float value reading error while reading file ".\jsoncons_examples\output\booklist2.json"
Describe the bug
Parser should also read integer value .
In the given sample "price" value is not being read by parser. While reading integer value program is throwing exception in file json_parser.hpp at line number 1113. I have also attached image where error is occurring.
[ { "author": "Haruki Murakami", "category": "Fiction", "date": "2006-01-03", "isbn": "1400079276", "price": 13.45, "title": "Kafka on the Shore" }, { "author": "Charles Bukowski", "category": "Fiction", "date": "2004-07-08", "isbn": "1852272007", "price": 22.48, "ratings": { "*****": 4 }, "title": "Pulp" }, { "author": "Haruki Murakami", "category": "Fiction", "date": "2002-04-09", "isbn": "037571894X", "price": 9.01, "title": "A Wild Sheep Chase: A Novel" }, { "author": "George Crile", "category": "History", "date": "2007-11-06", "isbn": "0802143415", "price": 10.5, "title": "Charlie Wilson's War" } ]
Enumerate the steps to reproduce the bug
Run given sample code.
C+++ code
void read_nested_objects_to_basic_json() { std::ifstream is("C:\vsts\ABI\Src\jsoncons_examples\output\booklist2.json"); assert(is);
}
Include a small, self-contained example if possible
What compiler, architecture, and operating system? os - windows 10 compiler - visual studio visual c++ version 2022
**What jsoncons library version? Latest release 0.171.0