Browse Source

[skip ci] fix indent spelling

1.8.x
Syping 1 year ago
parent
commit
a882738735
  1. 26
      qjson4/QJsonDocument.cpp
  2. 2
      qjson4/QJsonDocument.h

26
qjson4/QJsonDocument.cpp

@ -199,7 +199,7 @@ QString QJsonDocument::escapeString(const QString &s) const {
//------------------------------------------------------------------------------
// Name: toJson
//------------------------------------------------------------------------------
QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format, int intend) const {
QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format, int indent) const {
QString b;
QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text);
@ -234,17 +234,17 @@ QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format, int intend
QJsonArray::const_iterator it = a.begin();
QJsonArray::const_iterator e = a.end();
if (!compact) ss << QByteArray(4*intend, ' ');
ss << toJson(*it++, format, intend+1);
if (!compact) ss << QByteArray(4*indent, ' ');
ss << toJson(*it++, format, indent+1);
for(;it != e; ++it) {
ss << (compact ? "," : ",\n");
if (!compact) ss << QByteArray(4*intend, ' ');
ss << toJson(*it, format, intend+1);
if (!compact) ss << QByteArray(4*indent, ' ');
ss << toJson(*it, format, indent+1);
}
}
intend--;
ss << (compact ? "]" : QString("\n%1]").arg(QString(4*intend, ' ')));
indent--;
ss << (compact ? "]" : QString("\n%1]").arg(QString(4*indent, ' ')));
}
break;
case QJsonValue::Object:
@ -255,17 +255,17 @@ QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format, int intend
QJsonObject::const_iterator it = o.begin();
QJsonObject::const_iterator e = o.end();
if (!compact) ss << QByteArray(4*intend, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, intend+1);
if (!compact) ss << QByteArray(4*indent, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
++it;
for(;it != e; ++it) {
ss << (compact ? "," : ",\n");
if (!compact) ss << QByteArray(4*intend, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, intend+1);
if (!compact) ss << QByteArray(4*indent, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
}
}
intend--;
ss << (compact ? "}" : QString("\n%1}").arg(QString(4*intend, ' ')));
indent--;
ss << (compact ? "}" : QString("\n%1}").arg(QString(4*indent, ' ')));
}
break;
case QJsonValue::Undefined:

2
qjson4/QJsonDocument.h

@ -88,7 +88,7 @@ public:
private:
void setRoot(const QJsonRoot &root);
QString toJson(const QJsonValue &v, JsonFormat format, int intend = 1) const;
QString toJson(const QJsonValue &v, JsonFormat format, int indent = 1) const;
QString escapeString(const QString &s) const;
private:

Loading…
Cancel
Save