Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: JSON parser as a single Perl Regex

by Anonymous Monk
on Sep 27, 2012 at 01:34 UTC ( #995900=note: print w/ replies, xml ) Need Help??

in reply to JSON parser as a single Perl Regex

Its quicker to fail on buggy json than RFC: A walkthrough from JSON ABNF to Regexp::Grammars

sub fa { my $time = time; my $ref = from_json(@_); $time = time-$time; print "T$time ", Dumper( $ref ),"\n"; } fa(q{["double extra comma",,]}); ## THE BUGGY fa(q{[1,[2,[3],[]]]}); ## THE REGULAR fa( q{[{"k":"v"},{"v":"k"}] } ); fa( q{{"ro":["sham","bo"],"t":{"i":{"c":{"t":{"o":"c"}}}}}} ); __END__ T5 $VAR1 = 'no match'; T0 $VAR1 = [ 1, [ 2, [ 3 ], [] ] ]; T0 $VAR1 = [ { 'k' => 'v' }, { 'v' => 'k' } ]; T0 $VAR1 = { 'ro' => [ 'sham', 'bo' ], 't' => { 'i' => { 'c' => { 't' => { 'o' => 'c' } } } } };

Comment on Re: JSON parser as a single Perl Regex
Download Code
Replies are listed 'Best First'.
Re^2: JSON parser as a single Perl Regex
by merlyn (Sage) on Sep 27, 2012 at 14:12 UTC
    It'd probably fail much faster if I used ratcheting in VALUE.

    -- Randal L. Schwartz, Perl hacker

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995900]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2015-11-29 23:37 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (754 votes), past polls