These are chat archives for jsog/jsog

Jul 2015
Moody Salem
Jul 28 2015 22:26
Jeff, the javascript implementation of the JSOG decoder assumes that each @ref is encountered after the corresponding @id in the serialization. Map implementations do not necessarily preserve key insertion order, and neither does JSON.parse. As a result, the algorithm cannot be copied to other platforms reliably. The example implementation of a parser should be rewritten IMO to handle the general case where a @ref can point to an @id anywhere in the JSON. My idea is that you would 1. loop through the JSON to get a map of all @id values to their corresponding objects 2. loop through the JSON to get a map of @ref values to an array of dictionary/keys || array/indices 3. loop through all the ref points and look up the @id, throwing an exception if an ID is not found. Steps 1 and 2 can be done together in a single pass.
Jeff Schnitzer
Jul 28 2015 23:35
If you're looking for an algorithm to copy for a platform that doesn't preserve map insertion order, look at the Python impl