ObjCObject.toJSON
Copy a supported Foundation value when JSON.stringify serializes a proxy.
js
object.toJSON()Arguments
No arguments.
Returns
Copied Foundation data: string, boolean, number, array, plain object or null. Large integers become BigInt, or decimal strings if BigInt is unavailable.
Example
js
const dictionary = ObjC.create("NSMutableDictionary");
try {
dictionary.set("message", "Hello");
console.log(JSON.stringify(dictionary)); // {"message":"Hello"}
} finally { dictionary.release(); }Notes
JSON.stringify calls this automatically. Unsupported native objects or BigInt values can still fail serialization. object is a returned proxy, not a global named ObjCObject.