Skip to content

Commit

Permalink
Merge pull request #277 from sergot/nom
Browse files Browse the repository at this point in the history
my $s removed
  • Loading branch information
FROGGS committed Jun 9, 2014
2 parents 7606343 + 7a6d6ec commit a7dd964
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/core/JSON/Pretty.pm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ my grammar JSONPrettyGrammar {

proto to-json($, :$indent = 0, :$first = 0) {*}

my $s = 2;
multi to-json(Version:D $v, :$indent = 0, :$first = 0) { to-json(~$v, :$indent, :$first) }
multi to-json(Real:D $d, :$indent = 0, :$first = 0) { (' ' x $first) ~ ~$d }
multi to-json(Bool:D $d, :$indent = 0, :$first = 0) { (' ' x $first) ~ ($d ?? 'true' !! 'false') }
Expand All @@ -104,12 +103,12 @@ multi to-json(Str:D $d, :$indent = 0, :$first = 0) {
}
multi to-json(Positional:D $d, :$indent = 0, :$first = 0) {
return (' ' x $first) ~ "\["
~ ($d ?? $d.map({ "\n" ~ to-json($_, :indent($indent + $s), :first($indent + $s)) }).join(",") ~ "\n" ~ (' ' x $indent) !! ' ')
~ ($d ?? $d.map({ "\n" ~ to-json($_, :indent($indent + 2), :first($indent + 2)) }).join(",") ~ "\n" ~ (' ' x $indent) !! ' ')
~ ']';
}
multi to-json(Associative:D $d, :$indent = 0, :$first = 0) {
return (' ' x $first) ~ "\{"
~ ($d ?? $d.map({ "\n" ~ to-json(.key, :first($indent + $s)) ~ ' : ' ~ to-json(.value, :indent($indent + $s)) }).join(",") ~ "\n" ~ (' ' x $indent) !! ' ')
~ ($d ?? $d.map({ "\n" ~ to-json(.key, :first($indent + 2)) ~ ' : ' ~ to-json(.value, :indent($indent + 2)) }).join(",") ~ "\n" ~ (' ' x $indent) !! ' ')
~ '}';
}

Expand Down

0 comments on commit a7dd964

Please sign in to comment.