timo / json_fast

a naive imperative json parser in perl6, to evaluate performance against JSON::Tiny
Artistic License 2.0
27 stars 20 forks source link

ArrayHash -> to-json -> Array of Pairs (of Hashes) #72

Closed gueriksson closed 4 years ago

gueriksson commented 4 years ago

This might be a problem for ArrayHash, not JSON::Fast, but when jsonfying a ArrayHash you get an array of hashes and that is not what I want. Is there a workaround? Or is this a feature demand/wish? Cf.:

https://colabti.org/irclogger/irclogger_log/raku?date=2020-08-12#l179

https://colabti.org/irclogger/irclogger_log/raku?date=2020-08-12#l211

(You get the same result if you bind to a hash instead of a array.)

timo commented 4 years ago

i just released version 0.15 of JSON::Fast which will prefer treating an object as Associative rather than Positional if it does both roles. This gives you the output you're looking for, and unless you set :sorted-keys you'll get the order that the object itself dictates

gueriksson commented 4 years ago

Great! That's really Fast! :-)