Permalink
Browse files

[JSON::Tiny] trim input before parsing it

This used to return "Any" because of the leading whitespace:

$ nom -e 'use JSON::Tiny; say from-json(q[   {}]).perl'
Any

But it now works:

$ nom -e 'use JSON::Tiny; say from-json(q[   {}]).perl'
{}

Closes #7.
  • Loading branch information...
masak committed Oct 20, 2012
1 parent 8584242 commit 121fff46d16c98d055b8e7d8f7ccf06011bdadb3
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/JSON/Tiny.pm
View
@@ -47,7 +47,7 @@ multi to-json(Any:D $s) {
sub from-json($text) is export {
my $a = JSON::Tiny::Actions.new();
- my $o = JSON::Tiny::Grammar.parse($text, :actions($a));
+ my $o = JSON::Tiny::Grammar.parse($text.trim, :actions($a));
return $o.ast;
}
# vim: ft=perl6

0 comments on commit 121fff4

Please sign in to comment.