MOP4Import-Declare

 view release on metacpan or  search on metacpan

Util/CommentedJson.pm  view on Meta::CPAN


our $re_ALL = qr{ [\[\]\{\},:]
                | (?<comment> $re_comment1 | $re_comment2)
                | $re_atom
                | $re_number
                | $re_string
              }xs;

sub strip_json_comments {
  my ($pack, $bytes) = @_;
  $bytes =~ s/\A\xef\xbb\xbf//; # Strip BOM of utf-8.
  my @region = reverse list_json_comments($pack, $bytes);
  foreach my $region (@region) {
    my ($startPos, $len) = @$region;
    substr($bytes, $startPos, $len, '');
  }
  $bytes;
}

sub list_json_comments {
  my @pos;



( run in 0.394 second using v1.01-cache-2.11-cpan-e9daa2b36ef )