fix(json): preserve existing values on duplicate insertion

This commit is contained in:
boykopovar committed 2026-10-21 21:45:10 +03:00
1 parent 6d2aebd469
commit fc3db15402
3 files changed
+9 -2

No files matched your search

-1
View File
@@ -1083,7 +1083,6 @@ void APS5_VABI _ZN3sce4Json6Object4PairD1Ev(Pair* self) {
ObjectIterator* APS5_VABI _ZN3sce4Json6Object6insertERKNS1_4PairE(ObjectIterator* result, Object* self, const Pair* pair) {
auto it = std::find_if(self->items->begin(), self->items->end(), [&](const Pair& p) { return *p.key.text == *pair->key.text; });
if (it != self->items->end()) {
AssignNode(NodeOf(it->value), NodeOf(pair->value));
result->it = it;
return result;
}
+8
View File
@@ -552,6 +552,14 @@ static void ObjectInsert() {
Require(std::strcmp(_ZNK3sce4Json6String5c_strEv(&p->key), "score") == 0);
Require(*_ZNK3sce4Json5Value10getIntegerEv(&p->value) == 100);
Require(_ZN3sce4Json5Value3setEl(&pair.value, 200) == 0);
Iterator duplicate{};
Require(_ZN3sce4Json6Object6insertERKNS1_4PairE(&duplicate, &object, &pair) == &duplicate);
Require(_ZNK3sce4Json6Object8iteratoreqERKS2_(&duplicate, &inserted));
Require(_ZNK3sce4Json6Object4sizeEv(&object) == 1);
Require(*_ZNK3sce4Json5Value10getIntegerEv(&_ZNK3sce4Json6Object8iteratordeEv(&duplicate)->value) == 100);
_ZN3sce4Json6Object8iteratorD1Ev(&duplicate);
String otherKey{};
_ZN3sce4Json6StringC1EPKc(&otherKey, "other");
Value otherValue{};
+1 -1
View File
@@ -10,4 +10,4 @@
- [sce::Json::MemAllocator::notifyError](../../../core/libs/prx/libSceJson2/Export.cpp) (libSceJson2) - the base class's virtual does nothing. A title's allocator that does not override it calls it through its own vtable; the library never calls the title's allocator, so it never reports an allocation failure. Whether the console's base implementation logs anything is unknown
- [sce::Json::String size, capacity, resize, compare and operator==(const String&), append(const char*, size_t), operator+=; Value::swap; Array::iterator and Object::iterator copy constructor, advance and operator==](../../../core/libs/prx/libSceJson2/Export.cpp) (libSceJson2) - the signatures follow the mangled names and the behaviour is that of the matching `std::string` or container operation, with no cited source in KytyPS5, shadPS4, SharpProspero or disassembly. `append(text, length)` throws on a null text with a non-zero length; `operator+=` returns the String; `Value::swap` exchanges the node pointers; `advance` moves the iterator in place, returns it, and does not check the distance against the end. Whether the console returns the iterator from `advance` and how it bounds it is unverified
- [sce::Json::Value::operator bool](../../../core/libs/prx/libSceJson2/Export.cpp) (libSceJson2) - member of `Value` returning `bool` as a conversion operator, with no cited source in KytyPS5, shadPS4, SharpProspero, or disassembly: evaluates to `false` for `TypeNull` and boolean `false`, and `true` for boolean `true`. For all other value types it currently returns `true`; whether the console converts them, throws, or checks container emptiness is unverified
- [sce::Json::Object::insert](../../../core/libs/prx/libSceJson2/Export.cpp) (libSceJson2) - signatures and behaviors have no cited source in KytyPS5, shadPS4, SharpProspero, or disassembly: `insert` returns an iterator through a result pointer before `this` as `Object::begin` does, and takes a const Pair reference. If the key exists, it updates the existing value and returns an iterator to it; otherwise it appends a deep copy of the pair and returns an iterator to the new element; whether the console updates existing keys, appends duplicates, or ignores duplicate insertion is unverified.
- [sce::Json::Object::insert](../../../core/libs/prx/libSceJson2/Export.cpp) (libSceJson2) - new keys are appended in insertion order; the system library uses key order. Duplicate insertion preserves the existing value.