Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: JSON parser as a single Perl Regex

by davido (Archbishop)
on Oct 19, 2013 at 06:34 UTC ( #1058876=note: print w/replies, xml ) Need Help??


in reply to Re: JSON parser as a single Perl Regex
in thread JSON parser as a single Perl Regex

Prior to the time of this post there had already been JSON::PP and Mojo::JSON (which became JSON::Tiny in Oct2012)...

I just want to clarify this: If you skim to the bottom of the POD for JSON::Tiny you will find this:

ACKNOWLEDGEMENTS: ...to Randal Schwartz for showing the Los Angeles Perl Mongers (Sept 2012) his embeddable pure-regexp JSON parser, and explaining it on PerlMonks (995856). He wasn't involved in JSON::Tiny, but it was the exploration of alternatives to his solution that led to this fork of Mojolicious's JSON parser.

JSON::Tiny wouldn't exist if it weren't for two things: First, for the work that Sebastian and his team did to bring us Mojo::JSON as a component of the Mojolicious framework. And second, if merlyn hadn't elevated my interest in the topic by presenting his pure-regexp solution at Los Angeles Perl Mongers in September 2012.

I won't try to put words in his mouth or explain the rationale that he presented at LA-PM for the regexp monstrosity (or thing of beauty). My understanding was that he needed a light-weight JSON parser that he could embed in a $project. He was justifiably proud of the regular expression solution. And while it's certainly fewer lines of code than JSON::Tiny, I believed that there might be a more robust way to embed a pure-Perl JSON parser in a project.

A few days later I found myself thinking about it again, and remembered that one of Mojolicious's philosophies is to minimize external dependencies. That meant that Mojo::JSON should be pretty easy to adapt to a stand-alone module. ...and after working around its use of Mojo::Base and Mojo::Utils, the conversion to a standalone module that could (if absolutely necessary) be copy/pasted right into a code base was straight-forward; JSON::Tiny came into existence.

Mojo::JSON on its own wouldn't have worked for merlyn, because it relies on Mojo::Base and Mojo::Utils. I had to embed the functionality that Mojo::JSON needed from those two modules before JSON::Tiny could be made stand-alone. The test suite also required a bit of adaptation. The tests were almost all identical to their Mojo::JSON versions, but in JSON::Tiny the test suite had to emulate some of the support functionality that the Mojolicious framework would have provided.


Dave

  • Comment on Re^2: JSON parser as a single Perl Regex

Replies are listed 'Best First'.
Re^3: JSON parser as a single Perl Regex
by sedusedan (Monk) on Oct 19, 2013 at 10:39 UTC
    Thanks for posting this.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058876]
help
Chatterbox?
[karlgoethebier]: marioroy: Racket ball is considered harmful, like Squash
[marioroy]: Wait till folks see what MCE::Hobo can do in the upcoming release. Multiple instances, nested spawning, 3 levels, doesn't matter. it works on Windiows too.
[Lady_Aleena]: I hate sites that tell me to turn ad-blocker off. They should know better.
[marioroy]: s/Windiows/ Windows/
[Discipulus]: marioroy can you expand that Niagara's fall history?
erix only sees fallen angels
erix if it weren't for bad luck, I'd have no luck at all
Discipulus Windiows the OS of native americans..
[karlgoethebier]: marioroy: Next step: Write the ultimate book. "Parallel Programming With Perl. Yet Another Missing Manual" ;-)
[marioroy]: karlgoethebier I do not do Racket ball anymore. That was from gym class long ago.

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-05-29 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?