Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
420659f1
Commit
420659f1
authored
Jun 28, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addressing #272
parent
360f0f37
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
10 deletions
+16
-10
src/json.hpp
src/json.hpp
+6
-5
src/json.hpp.re2c
src/json.hpp.re2c
+6
-5
test/src/unit.cpp
test/src/unit.cpp
+4
-0
No files found.
src/json.hpp
View file @
420659f1
...
...
@@ -2097,6 +2097,8 @@ class basic_json
string_t
dump
(
const
int
indent
=
-
1
)
const
{
std
::
stringstream
ss
;
// fix locale problems
ss
.
imbue
(
std
::
locale
(
std
::
locale
(),
new
DecimalSeparator
));
if
(
indent
>=
0
)
{
...
...
@@ -5655,6 +5657,8 @@ class basic_json
// reset width to 0 for subsequent calls to this stream
o
.
width
(
0
);
// fix locale problems
o
.
imbue
(
std
::
locale
(
std
::
locale
(),
new
DecimalSeparator
));
// do the actual serialization
j
.
dump
(
o
,
pretty_print
,
static_cast
<
unsigned
int
>
(
indentation
));
...
...
@@ -6128,11 +6132,8 @@ class basic_json
// string->double->string or string->long
// double->string; to be safe, we read this value from
// std::numeric_limits<number_float_t>::digits10
std
::
stringstream
ss
;
ss
.
imbue
(
std
::
locale
(
std
::
locale
(),
new
DecimalSeparator
));
// fix locale problems
ss
<<
std
::
setprecision
(
std
::
numeric_limits
<
double
>::
digits10
)
<<
m_value
.
number_float
;
o
<<
ss
.
str
();
o
<<
std
::
setprecision
(
std
::
numeric_limits
<
double
>::
digits10
)
<<
m_value
.
number_float
;
}
return
;
}
...
...
src/json.hpp.re2c
View file @
420659f1
...
...
@@ -2097,6 +2097,8 @@ class basic_json
string_t dump(const int indent = -1) const
{
std::stringstream ss;
// fix locale problems
ss.imbue(std::locale(std::locale(), new DecimalSeparator));
if (indent >= 0)
{
...
...
@@ -5655,6 +5657,8 @@ class basic_json
// reset width to 0 for subsequent calls to this stream
o.width(0);
// fix locale problems
o.imbue(std::locale(std::locale(), new DecimalSeparator));
// do the actual serialization
j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
...
...
@@ -6128,11 +6132,8 @@ class basic_json
// string->double->string or string->long
// double->string; to be safe, we read this value from
// std::numeric_limits<number_float_t>::digits10
std::stringstream ss;
ss.imbue(std::locale(std::locale(), new DecimalSeparator)); // fix locale problems
ss << std::setprecision(std::numeric_limits<double>::digits10)
<< m_value.number_float;
o << ss.str();
o << std::setprecision(std::numeric_limits<double>::digits10)
<< m_value.number_float;
}
return;
}
...
...
test/src/unit.cpp
View file @
420659f1
...
...
@@ -14079,6 +14079,10 @@ TEST_CASE("regression tests")
CHECK
(
j1a
.
dump
()
==
"23.42"
);
CHECK
(
j1b
.
dump
()
==
"23.42"
);
std
::
stringstream
ss
;
ss
<<
j1a
;
CHECK
(
ss
.
str
()
==
"23.42"
);
CHECK
(
j2a
.
dump
()
==
"23.42"
);
//issue #230
//CHECK(j2b.dump() == "23.42");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment