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

to-json doesn't like undefined values #4

Closed timo closed 6 years ago

timo commented 9 years ago

to-json(Any) and my $foo; to-json($foo) should both generate "null".

jonathanstowe commented 8 years ago

I'm going to look at this because:

[jonathan@coriolanus JSON-Marshal]$ perl6 -e 'use JSON::Fast; say to-json({foo => Str})'
Cannot unbox a type object
  in sub str-escape at sources/A670982EBE56A59B3A7611E194FB56A852C763B3 (JSON::Fast) line 5
  in sub to-json at sources/A670982EBE56A59B3A7611E194FB56A852C763B3 (JSON::Fast) line 16
  in sub to-json at sources/A670982EBE56A59B3A7611E194FB56A852C763B3 (JSON::Fast) line 39
  in block <unit> at -e line 1

It's interfering with my ability to switch to JSON::Fast

CurtTilmes commented 7 years ago

Still fails for (Int), (Rat), (Num) which are processed before the return 'null' if not $obj.defined check. I'd recommend moving it above those. One could argue about (Bool -- Should that be null or false? It might break things if you change it now, so I'd recommend still leaving that as it is.

jonathanstowe commented 6 years ago

Can I :+1: a surprising two and a half year later close?

timo commented 6 years ago

sure. sorry for not keeping this issue tracker updated as i changed things :(