Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: json return value

by marto (Archbishop)
on Jul 11, 2013 at 08:42 UTC ( #1043657=note: print w/replies, xml ) Need Help??

in reply to json return value

The first thing I'd do is to ensure your server script runs without problems, perhaps you don't have the JSON module installed, perl does not have JSON as part of it's core module set. Running the script from the command line will throw errors if a module is missing, apache will throw an error and your client won't be able to get a valid response. Various debugging techniques are covered in CGI Help Guide from CGI Programming.

Update: to install JSON from the command prompt:

cpan JSON

Or speak to your systems administrator.

Replies are listed 'Best First'.
Re^2: json return value
by tobyink (Abbot) on Jul 11, 2013 at 09:06 UTC

    "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

      Apologies, You are correct. I was going by core modules listed on, 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.

      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

      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.


        use JSON;


        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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043657]
[Discipulus]: good morning nuns and monks!

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2018-06-25 07:14 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.