Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'source/core')
-rw-r--r--source/core/StarJson.cpp14
-rw-r--r--source/core/StarJsonParser.hpp9
2 files changed, 16 insertions, 7 deletions
diff --git a/source/core/StarJson.cpp b/source/core/StarJson.cpp
index 83b4e67..04ac544 100644
--- a/source/core/StarJson.cpp
+++ b/source/core/StarJson.cpp
@@ -981,9 +981,17 @@ void Json::getHash(XXHash3& hasher) const {
json.getHash(hasher);
}
else if (type == Json::Type::Object) {
- for (auto const& pair : *m_data.get<JsonObjectConstPtr>()) {
- hasher.push(pair.first.utf8Ptr(), pair.first.utf8Size());
- pair.second.getHash(hasher);
+ auto& object = *m_data.get<JsonObjectConstPtr>();
+ List<JsonObject::const_iterator> iterators;
+ iterators.reserve(object.size());
+ for (auto i = object.begin(); i != object.end(); ++i)
+ iterators.append(i);
+ iterators.sort([](JsonObject::const_iterator a, JsonObject::const_iterator b) {
+ return a->first < b->first;
+ });
+ for (auto& iter : iterators) {
+ hasher.push(iter->first.utf8Ptr(), iter->first.utf8Size());
+ iter->second.getHash(hasher);
}
}
}
diff --git a/source/core/StarJsonParser.hpp b/source/core/StarJsonParser.hpp
index 91d93bb..c7a9cc6 100644
--- a/source/core/StarJsonParser.hpp
+++ b/source/core/StarJsonParser.hpp
@@ -521,11 +521,12 @@ public:
}
void endObject() {
+ if (currentState() == ObjectElement) {
+ if (m_pretty)
+ write('\n');
+ indent();
+ }
popState(Object);
-
- if (m_pretty)
- write('\n');
- indent();
write('}');
}