You are reading content from Scuttlebutt
@aljoscha %vn1IyTU5EJTvfpmUPIpkbWCGYwgpJjHX85f4VNhNIro=.sha256
Re: %ZOosXgUtS

@Dominic

I got some neurons crossed there, when I said "lexiographic order" I should have said "insertion order"

Ok, that actually works. Input order is preserver, except all keys that are either 0 or match /[1-9][0-9]*/ are moved to the top, sorted lexicographically among themselves. Just implemented this, and the rust impl now passes the full test set.

@aljoscha also I think you are greatly overstating the risk that the order of JSON fields will change. Firstly, that's not part of node.js, it's a part of V8, who are both more conservative and more competent.
They won't change it because it's been this way for ages and they'll break the web.

Fair enough, but I'd still prefer if sbot explicitly implemented that behavior rather than relying on unspecified details, even if they realistically won't change. I'll clean up the rust implementation next, and then I can create js bindings as (nearly) drop-in replacements for JSON.stringify and JSON.parse, with the ordering semantics ssb needs.

Maybe you could already think about how those could be switched in, and whether/how to benchmark the performance impact. I honestly don't know whether they should be faster or slower than v8's JSON handling.

The js interface of the bindings fill be slightly different from JSON.foo: The parsing function won't support revivers, and the serialization function will come in two, unconfigurable varieties: One for whitespace-less encoding, and one for ssb's signing-format encoding.

Join Scuttlebutt now