Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
43dbe02d
Commit
43dbe02d
authored
Nov 21, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐛
fixing #359
parent
0d72767b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
46 deletions
+4
-46
json.hpp
src/json.hpp
+2
-23
json.hpp.re2c
src/json.hpp.re2c
+2
-23
No files found.
src/json.hpp
View file @
43dbe02d
...
@@ -122,26 +122,6 @@ struct has_mapped_type
...
@@ -122,26 +122,6 @@ struct has_mapped_type
std
::
is_integral
<
decltype
(
detect
(
std
::
declval
<
T
>
()))
>::
value
;
std
::
is_integral
<
decltype
(
detect
(
std
::
declval
<
T
>
()))
>::
value
;
};
};
/*!
@brief helper class to create locales with decimal point
This struct is used a default locale during the JSON serialization. JSON
requires the decimal point to be `.`, so this function overloads the
`do_decimal_point()` function to return `.`. This function is called by
float-to-string conversions to retrieve the decimal separator between integer
and fractional parts.
@sa https://github.com/nlohmann/json/issues/51#issuecomment-86869315
@since version 2.0.0
*/
struct
DecimalSeparator
:
std
::
numpunct
<
char
>
{
char
do_decimal_point
()
const
{
return
'.'
;
}
};
}
}
/*!
/*!
...
@@ -2201,8 +2181,7 @@ class basic_json
...
@@ -2201,8 +2181,7 @@ class basic_json
{
{
std
::
stringstream
ss
;
std
::
stringstream
ss
;
// fix locale problems
// fix locale problems
const
static
std
::
locale
loc
(
std
::
locale
(),
new
DecimalSeparator
);
ss
.
imbue
(
std
::
locale
::
classic
());
ss
.
imbue
(
loc
);
// 6, 15 or 16 digits of precision allows round-trip IEEE 754
// 6, 15 or 16 digits of precision allows round-trip IEEE 754
// string->float->string, string->double->string or string->long
// string->float->string, string->double->string or string->long
...
@@ -5829,7 +5808,7 @@ class basic_json
...
@@ -5829,7 +5808,7 @@ class basic_json
o
.
width
(
0
);
o
.
width
(
0
);
// fix locale problems
// fix locale problems
const
auto
old_locale
=
o
.
imbue
(
std
::
locale
(
std
::
locale
(),
new
DecimalSeparator
));
const
auto
old_locale
=
o
.
imbue
(
std
::
locale
::
classic
(
));
// set precision
// set precision
// 6, 15 or 16 digits of precision allows round-trip IEEE 754
// 6, 15 or 16 digits of precision allows round-trip IEEE 754
...
...
src/json.hpp.re2c
View file @
43dbe02d
...
@@ -122,26 +122,6 @@ struct has_mapped_type
...
@@ -122,26 +122,6 @@ struct has_mapped_type
std::is_integral<decltype(detect(std::declval<T>()))>::value;
std::is_integral<decltype(detect(std::declval<T>()))>::value;
};
};
/*!
@brief helper class to create locales with decimal point
This struct is used a default locale during the JSON serialization. JSON
requires the decimal point to be `.`, so this function overloads the
`do_decimal_point()` function to return `.`. This function is called by
float-to-string conversions to retrieve the decimal separator between integer
and fractional parts.
@sa https://github.com/nlohmann/json/issues/51#issuecomment-86869315
@since version 2.0.0
*/
struct DecimalSeparator : std::numpunct<char>
{
char do_decimal_point() const
{
return '.';
}
};
}
}
/*!
/*!
...
@@ -2201,8 +2181,7 @@ class basic_json
...
@@ -2201,8 +2181,7 @@ class basic_json
{
{
std::stringstream ss;
std::stringstream ss;
// fix locale problems
// fix locale problems
const static std::locale loc(std::locale(), new DecimalSeparator);
ss.imbue(std::locale::classic());
ss.imbue(loc);
// 6, 15 or 16 digits of precision allows round-trip IEEE 754
// 6, 15 or 16 digits of precision allows round-trip IEEE 754
// string->float->string, string->double->string or string->long
// string->float->string, string->double->string or string->long
...
@@ -5829,7 +5808,7 @@ class basic_json
...
@@ -5829,7 +5808,7 @@ class basic_json
o.width(0);
o.width(0);
// fix locale problems
// fix locale problems
const auto old_locale = o.imbue(std::locale
(std::locale(), new DecimalSeparator
));
const auto old_locale = o.imbue(std::locale
::classic(
));
// set precision
// set precision
// 6, 15 or 16 digits of precision allows round-trip IEEE 754
// 6, 15 or 16 digits of precision allows round-trip IEEE 754
...
...
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