This question evaluates understanding of deterministic, cross-language JSON serialization and deserialization for object graphs with cycles, including concepts such as cycle detection, stable object identifiers, preservation of shared subobjects, traversal-order determinism, input validation/security, and time/space complexity.
You are designing a JSON-based serializer/deserializer for a graph of objects composed of dictionaries and primitives (str, int, float, bool, null). Objects may share subobjects and may contain cycles (e.g., two dictionaries referencing each other via a "partner" key).
Assume memory addresses are not stable across runs/languages, and the format must be readable/writable by multiple languages.
Design and justify a strategy that:
Two dictionaries reference each other via a partner field:
Describe your on-the-wire JSON format and the algorithms to serialize and deserialize such structures deterministically and safely.
Login required