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

array of hashes #13

Closed bduggan closed 8 years ago

bduggan commented 8 years ago

Hello,

I'm seeing some issues trying to serialize an array of hashes:

https://github.com/bduggan/json_fast/commit/2e2da5196c7f987cd0827e3c905e56e8a298f256

thanks Brian

bduggan commented 8 years ago

Never mind...I see that this construct is interpreted as a block rather than a hash. Sorry for the noise.

timo commented 8 years ago

actually, what you're running into is that [ ] with just a single thing in it will iterate that thing ("single-argument rule"), so [ { a => 1, b => 2 } ] will always be a list of pairs.

You can get around that by spelling it like [ { a => 1, b => 2 }, ] with the trailing comma.

bduggan commented 8 years ago

Cool, thanks!