Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: json return value

by tobyink (Abbot)
on Jul 11, 2013 at 09:06 UTC ( #1043665=note: print w/ replies, xml ) Need Help??


in reply to Re: json return value
in thread json return value

"perl does not have JSON as part of it's core module set"

True, but recent versions of Perl do have JSON::PP, which provides an almost identical API. The OP could consider switching to that if he doesn't have JSON and doesn't want to install it.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name


Comment on Re^2: json return value
Re^3: json return value
by marto (Chancellor) on Jul 11, 2013 at 09:16 UTC

    I don't see this listed as a core module as of 5.18, perhaps some distributions of Perl do have this as they tend to package non core modules and among other things.

    Update: fixed typo.

      $ corelist -a JSON::PP Data for 2013-05-20 JSON::PP was first released with perl v5.13.9 v5.13.9 2.27103 v5.13.10 2.27103 v5.13.10 2.27103 v5.13.11 2.27105 v5.14.0 2.27105 v5.14.1 2.27105 v5.14.2 2.27105 v5.14.3 2.27105 v5.14.4 2.27105 v5.15.0 2.27200 v5.15.1 2.27200 v5.15.2 2.27200 v5.15.3 2.27200 v5.15.4 2.27200 v5.15.5 2.27200 v5.15.6 2.27200 v5.15.7 2.27200 v5.15.8 2.27200 v5.15.9 2.27200 v5.16.0 2.27200 v5.16.1 2.27200 v5.16.2 2.27200 v5.16.3 2.27200 v5.17.0 2.27200 v5.17.1 2.27200 v5.17.2 2.27200 v5.17.3 2.27200 v5.17.4 2.27200 v5.17.5 2.27200 v5.17.6 2.27200 v5.17.7 2.27200 v5.17.8 2.27200 v5.17.9 2.27200 v5.17.10 2.27202 v5.17.10 2.27202 v5.17.11 2.27202 v5.18.0 2.27202 v5.19.0 2.27202

        Thanks. I was just about to post a reply, I've installed 5.18 and see that JSON::PP is installed. Am I missing something or should this be listed on the core modules section of http://perldoc.perl.org?

Re^3: json return value
by marto (Chancellor) on Jul 11, 2013 at 10:07 UTC

    Apologies, You are correct. I was going by core modules listed on http://perldoc.perl.org, as I didn't have perl installed on the machine I was posting from at the time.

    Update: This seems to be a problem. I'll investigate further and report the issue with the documentation maintainers.

Re^3: json return value
by stenasc (Novice) on Jul 12, 2013 at 10:18 UTC

    Hi, Thanks to all that replied. Just found out that the web hosts cannot install json as the website is on a shared server. However JSON::PP looks to be installed. I'm unsure of the changes that need to be made in the server and client code to ensure it works with JSON::PP. Any help greatly appreciated.

      Replace:

      use JSON;

      with

      use JSON::PP;

      Then test your code. As of v2 JSON determines if JSON::XS is installed, and falls back to using JSON::PP if the XS version isn't available. Perhaps you have an old version of JSON installed. You could also use local::lib to install modules to a directory under your control, and load them from there.

        First thing I did. It made no difference. It looks as if the server is returning something, but just not the json response. THe perl code seems fine..well no syntax error anyway. I tried to get it to print out a log file in the cgi-bin directory, but there are probably no write permissions for that dir. Thinking it's a directory issue..just dunno. For such a simple thing...can't believe there are so little examples out there.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-11-27 14:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (184 votes), past polls