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

IntStr.new(0, '') creates a broken json that can not be parsed anymore #26

Closed ufobat closed 7 years ago

ufobat commented 7 years ago

This code:

        dd %.data;
        say to-json( %.data ); 

produces this output:

Hash %!data = {:host("xxxx.loc"), :password("xxxx"), :port(8443), :prefix(IntStr.new(0, "")), :protocol("http"), :user("xxx")}
{
  "port": 8443,
  "prefix": ,
  "protocol": "http",
  "host": "xxxx.loc",
  "password": "xxx",
  "user": "xxx"
}

The problem is the "prefix": ,

timo commented 7 years ago

fixed this; in the same commit i taught json::fast to output rats and nums with an .0 or e0 at the end to disambiguate from Int. cheers