in reply to Malformed JSON Error Piwigo

The code has no error/warning check, for returned content.

I think the problem area is:

my $response = $ua->post( $conf{base_url}.'/ws.php?format=json', { method => 'pwg.categories.getImages', cat_id => $params{album_id}, per_page => 1000000, } ); foreach my $image_href (@{from_json($response->content)->{result}{ +images}}) { $photos_of_album{ $params{album_id} }{ $image_href->{file} } = + $image_href->{id}; }
It looks like the web server is trying to return a WARNING in the returned content.
The programmer should check $response->content for Errors/warnings prior to calling "from_json".

I would probably place the blame on the server programmer, for not returning the error/warning in JSON format, as requested.

        ...Disinformation is not as good as datinformation.               Don't document the program; program the document.

Replies are listed 'Best First'.
Re^2: Malformed JSON Error Piwigo
by kiteboywales (Initiate) on Apr 26, 2017 at 17:48 UTC

    Just to be clear do you mean the script is dodgy itself or the response from the hosting provider which is Awardspace

    Apologies all noob queries

      Both sides.

      The script you are using to fetch data from the server expects JSON back, and croaks if it does not get it.
      That part could be improved with Error/Warning detection and handling.

      The server side code that runs on the hosting service is what provides a response to a request from your clinet script.
      That should also behave itself when JSON is requested, and provide a JSON-only response.
      Apparently, it is not doing so in this case - it is sending an HTML style warning message.
      You can blame (lack of) documentation for this, and/or poor design/coding/testing.

              ...Disinformation is not as good as datinformation.               Don't document the program; program the document.