There is now a "JSON" compiler: perldoc compilers/json/JSON.pir
We need more tests (t/compilers/json/to_parrot.t) that test the
_dumper() output of a PMC generated by converting from a JSON string.
E.g.:
""
Would convert to an empty string, which would then be dumped as:
"JSON" => ""
See http://www.json.org/ for a description of the JSON grammar: all
elements of that grammar should be tested.
For failing tests, TODO them, and I'll be happy to fix the compiler.
Unless you beat me to it, which is fine.
As of the opening of this ticket, expect arrays and objects to fail
(need TGE support), true/false/null to work, and strings & numbers to
partially work.
Regards.
--
Will "Coke" Coleda
wi...@coleda.com
> Index: t/compilers/json/to_parrot.t
> ===================================================================
> --- t/compilers/json/to_parrot.t (revision 14622)
> +++ t/compilers/json/to_parrot.t (working copy)
> @@ -6,7 +6,7 @@
> use lib qw( t . lib ../lib ../../lib );
>
> use Test::More;
> -use Parrot::Test tests => 52;
> +use Parrot::Test tests => 60;
>
> =head1 NAME
>
> @@ -34,6 +34,56 @@
> "JSON" => "json"
> OUT
>
> +json_isnt('a', 'strings need quotes');
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash "');
> +"\"json\""
> +JSON
> +"JSON" => "\"json\""
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash \\');
> +"\\json\\"
> +JSON
> +"JSON" => "\\json\\"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with / (no backslash
> required)');
> +"/json/"
> +JSON
> +"JSON" => "/json/"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash b');
> +"\bjson\b"
> +JSON
> +"JSON" => "\bjson\b"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash f');
> +"\fjson\f"
> +JSON
> +"JSON" => "\fjson\f"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash n');
> +"\njson\n"
> +JSON
> +"JSON" => "\njson\n"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash r');
> +"\rjson\r"
> +JSON
> +"JSON" => "\rjson\r"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash t');
> +"\tjson\t"
> +JSON
> +"JSON" => "\tjson\t"
> +OUT
> +
> json_dump_is(<<'JSON', <<'OUT', 'number int');
> 1
> JSON
> @@ -628,7 +678,6 @@
> ]
> OUT
>
> -json_isnt('a', 'strings need quotes');
>
> # XXX Need many more tests, exercising all aspects of http://
> www.json.org/