[Jifty-commit] r4460 - in jifty/trunk: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Nov 17 23:53:51 EST 2007


Author: sterling
Date: Sat Nov 17 23:53:50 2007
New Revision: 4460

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/JSON.pm

Log:
 r14120 at dynpc145:  andrew | 2007-11-17 22:53:30 -0600
 Adding SYNOPSIS, LICENSE, and code comments.


Modified: jifty/trunk/lib/Jifty/JSON.pm
==============================================================================
--- jifty/trunk/lib/Jifty/JSON.pm	(original)
+++ jifty/trunk/lib/Jifty/JSON.pm	Sat Nov 17 23:53:50 2007
@@ -7,6 +7,14 @@
 
 Jifty::JSON -- Wrapper around L<JSON>
 
+=head1 SYNOPSIS
+
+  use Jifty::JSON;
+
+  # Even though you might be using JSON::Syck, use the original JSON names
+  my $obj  = jsonToObj(q! { 'x': 1, 'y': 2, 'z': 3 } !);
+  my $json = objToJson($obj);
+
 =head1 DESCRIPTION
 
 Provides a wrapper around the L<JSON> library.
@@ -26,14 +34,21 @@
 =cut
 
 BEGIN {
+    # Errors that happen here, stay here.
     local $@;
+
+    # We're hacking, so tell the nannies to leave for a minute
     no strict 'refs';
     no warnings 'once';
+
+    # If a good version of JSON::Syck is available use that...
     if (eval { require JSON::Syck; JSON::Syck->VERSION(0.05) }) {
         *jsonToObj = *_jsonToObj_syck;
         *objToJson = *_objToJson_syck;
         $JSON::Syck::ImplicitUnicode = 1;
     }
+
+    # Bummer, fallback to the pure Perl implementation
     else {
         require JSON;
         *jsonToObj = *_jsonToObj_pp;
@@ -113,4 +128,11 @@
     return JSON::objToJson($obj, $args);
 }
 
+=head1 LICENSE
+
+Jifty is Copyright 2005-2006 Best Practical Solutions, LLC.
+Jifty is distributed under the same terms as Perl itself.
+
+=cut
+
 1;


More information about the Jifty-commit mailing list