Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 121fff46d16c98d055b8e7d8f7ccf06011bdadb3 1 parent 8584242
@masak masak authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/JSON/Tiny.pm
View
2  lib/JSON/Tiny.pm
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.