Skip to content

Commit

Permalink
Implement RFC7159. Closes #22
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Jan 12, 2016
1 parent c75a04c commit 9888329
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README
Expand Up @@ -4,6 +4,9 @@ A simple Perl 6 module for serializing and deserializing JSON.
say from-json('{ "a": 42 }').perl;
say to-json { a => [1, 2, 'b'] };

JSON::Tiny implements RFC7159, which is a superset of ECMA-404, in that it
permits any value as a top-level JSON string, not just arrays and objects.

All files (unless noted otherwise) can be used, modified and redistributed
under the terms of the Artistic License Version 2. Examples (in the
documentation, in tests or distributed as separate files) can be considered
Expand Down
2 changes: 1 addition & 1 deletion lib/JSON/Tiny/Actions.pm
@@ -1,7 +1,7 @@
unit class JSON::Tiny::Actions;

method TOP($/) {
make $/.values.[0].made;
make $<value>.made;
};
method object($/) {
make $<pairlist>.made.hash.item;
Expand Down
2 changes: 1 addition & 1 deletion lib/JSON/Tiny/Grammar.pm
@@ -1,7 +1,7 @@
use v6;
unit grammar JSON::Tiny::Grammar;

token TOP { ^ \s* [ <object> | <array> ] \s* $ }
token TOP { \s* <value> \s* }
rule object { '{' ~ '}' <pairlist> }
rule pairlist { <pair> * % \, }
rule pair { <string> ':' <value> }
Expand Down
2 changes: 1 addition & 1 deletion t/01-parse.t
Expand Up @@ -143,6 +143,7 @@ my @t =
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}>>,
Q<<"As of RFC 7159, a bare literal can be a JSON string too.">>,
;

my @n =
Expand All @@ -151,7 +152,6 @@ my @n =
'{ 3 : tru }', # not quite true
'{ "a : false }', # missing quote
# stolen from JSON::XS, 18_json_checker.t
Q<<"A JSON payload should be an object or array, not a string.">>,
Q<<{"Extra value after close": true} "misplaced quoted value">>,
Q<<{"Illegal expression": 1 + 2}>>,
Q<<{"Illegal invocation": alert()}>>,
Expand Down

0 comments on commit 9888329

Please sign in to comment.