feat(json2): implement sce::Json values, strings, arrays, objects, parser and null-access callback #57
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/57"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-28T03:42:52Z.
What
libSceJson2exported only theInitializerandMemAllocatorconstructors and destructors, plusinitialize. A retail title parses and builds JSON throughsce::Jsonand needs the rest. This implements:Value: constructors for every type and copy, assignment,setoverloads, typed getters,getType,count,operator[]by key and index,referValue/referArray/referObject,serialize,toString.String,ArrayandObjectwith their iterators.Parser::parse.Initializer::terminateandInitializer::setGlobalNullAccessCallBack.How
String,Array,ObjectandValueare pointer-sized handles to host-side storage. The title storesString/Array/Objectat an 8-byte stride andValuein 0x20-byte slots, so none of them can be bigger. The pair anObject::iteratordereferences to has its key at +0x00 and itsValueat +0x10, which the title reads directly. Array and object iterators are 8 bytes.int64becomeInteger, larger non-negative onesUInteger, and everything elseReal.\uescapes, including surrogate pairs, are decoded to UTF-8.parsereturns a negative code (0x80920101) and leaves the target value untouched.%.17g, and a non-finite real throws.operator[]). Otherwise a static default value of the requested type is returned.terminateclears the callback.getInteger/getUInteger/getRealconvert between the integer kinds and to real where the value fits.setGlobalNullAccessCallBack(NID00oCq0RwSAY) was identified by hashing its mangled name.MemAllocator's base constructor and destructor install the abstract class's vtable. A derived allocator replaces it with its own, so its entries (which throw, like a pure virtual call) run only if a pure virtual is called.Initializer::initializethrows on a null parameter instead of silently accepting it.referArrayon a string, etc.) throws.Testing
New
guest_jsontest:UIntegeraboveINT64_MAX, a\uescape and nested arrays. It is serialised to an exact expected string, re-parsed and serialised again to the same text.operator[]inserts in order and returns the same slot for an existing key; iteration yields the keys, with each pair'sValueat +0x10.push_back,size,backand iteration.terminatethe callback isn't called.