[BlueOnyx:17055] Re: JSON

Michael Stauber mstauber at blueonyx.it
Sat Feb 14 12:02:22 -05 2015


Hi Richard,

> They are saying that it doesn't appear to be
> parsing Json but does on a test server they have. Would there be a specific
> error log that would show this or how would I go about troubleshooting this?

Depends. It's a PHP script, so the errors should go into
/var/log/httpd/error_log - unless the php.ini or the runtime
configuration of the script tell it to not log errors.

Best way to test this would be a simple JSON test script:


<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo "<pre>";
print_r($arr);
echo "</pre><br>";
$encode = json_encode($arr);
echo "<pre>" . $encode . "</pre><br>";
$decode = json_decode($encode);
echo "<pre>";
print_r($decode);
echo "</pre><br>";
?>

That sets up an array and prints it. Then it encodes an array in JSON
and prints it, too. Then it decodes that JSON encoded array and prints
it again.

This will verify whether encoding and decoding via JSON work.

Most likely it will work for you, too. Which will then raise the
question about why the "other script" doesn't work.

The real question there is:

What does it try to encode/decode via JSON? Where does that JSON-blob
come from? Is that file readable, has it the correct UID/GID? Does it
contain an array or JSON encoded array to begin with?

If the "other script" is trying to JSON-decode something from an remote
URL, then most likely it runs into the restrictive PHP security settings
that usually deny "allow_url_fopen".

So I'd suggest to take a closer look at what that "other script" does
and where it gets its data from for the JSON encoding/decoding. The
problem is probably not JSON, but basic access rights or security
settings of PHP.

-- 
With best regards

Michael Stauber



More information about the Blueonyx mailing list