Skip to content

Commit

Permalink
Merge pull request #34 from naihil/serialization
Browse files Browse the repository at this point in the history
Change conversion to double in serialization
  • Loading branch information
gaudecker committed Apr 10, 2015
2 parents a4b690c + 0ae89a8 commit 6011c37
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,12 @@ namespace QtJson {
(data.type() == QVariant::ByteArray)) {// a string or a byte array?
str = sanitizeString(data.toString()).toUtf8();
} else if (data.type() == QVariant::Double) { // double?
double value = data.toDouble();
if ((value - value) == 0.0) {
double value = data.toDouble(&success);
if (success) {
str = QByteArray::number(value, 'g');
if (!str.contains(".") && ! str.contains("e")) {
str += ".0";
}
} else {
success = false;
}
} else if (data.type() == QVariant::Bool) { // boolean value?
str = data.toBool() ? "true" : "false";
Expand All @@ -155,9 +153,8 @@ namespace QtJson {

if (success) {
return str;
} else {
return QByteArray();
}
return QByteArray();
}

QString serializeStr(const QVariant &data) {
Expand Down

0 comments on commit 6011c37

Please sign in to comment.