3 ms·
It turns an object hierarchy into flat text. References in the object hierarchy can be circular, and the Depth parameter limits the infinite loop a circular re
by naikrovek 6y ago
It turns an object hierarchy into flat text. References in the object hierarchy can be circular, and the Depth parameter limits the infinite loop a circular reference would cause.
- chmod775 6y agoThis can't happen. JSON does not have references.
- Arnavion 6y ago>var obj = {}; obj.foo = obj; JSON.stringify(obj); >Uncaught TypeError: cyclic object value If browser JS engines can detect circular references, the PS serializer can too.
- naikrovek 6y agoit CAN, but it DOESN'T.
- db48x 6y agoDetecting circular structures (sometimes just called graphs), is a solved problem. The Lisp reader and printer even serialize them correctly: #1=(42 . #1#) makes a pair of two items. The first item is a 42 and the second is the pair itself. It sounds like whoever implemented this just didn't know what they were doing.