Fix unsigned long printed as signed long (issue #170)

This commit is contained in:
Benoit Blanchon
2016-04-28 08:42:59 +02:00
parent f192d5c12e
commit f9f002c8f7
11 changed files with 125 additions and 78 deletions

View File

@@ -72,8 +72,13 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
typename TypeTraits::EnableIf<TypeTraits::IsIntegral<T>::value>::type * =
0) {
using namespace Internals;
_type = JSON_INTEGER;
_content.asInteger = static_cast<JsonInteger>(value);
if (value >= 0) {
_type = JSON_POSITIVE_INTEGER;
_content.asInteger = static_cast<JsonInteger>(value);
} else {
_type = JSON_NEGATIVE_INTEGER;
_content.asInteger = static_cast<JsonInteger>(-value);
}
}
// Create a JsonVariant containing a string.