Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

improper json response

by sa624b@att.com (Initiate)
on Mar 16, 2012 at 15:54 UTC ( [id://960010]=perlquestion: print w/replies, xml ) Need Help??

sa624b@att.com has asked for the wisdom of the Perl Monks concerning the following question:

Can some one help me out, what exactly the fallowing message implies and what would be the solution. Thanks ... :-) malformed JSON string, neither array, object, number, string or atom, at charact er offset 0 (before "Not a SCALAR referen...") at test.pl line 109.

Replies are listed 'Best First'.
Re: improper json response
by choroba (Cardinal) on Mar 16, 2012 at 16:03 UTC
    You are trying to build a structure from a string that should be JSON, but it is not: instead, it contains a Perl error message "Not a SCALAR reference...". The source of the problem is probably the code that generates the JSON string, not the code that tries to read it.
Re: improper json response
by sundialsvc4 (Abbot) on Mar 16, 2012 at 19:23 UTC

    I ran into exactly the same problem (yes, on the server side) when I was trying to JSONify a structure which I forgot had a sub (that is, a code-reference) in it.   When my code referred to that element of the underlying structure, then I know that Perl will conveniently call the subroutine for me and hand me back the value ... which is what I intended ... but JSON-encoding routines are a bit more literal in their world-view.   I had to be very careful to prepare a data-structure for encoding purposes that contained nothing but values.   Yup, it was an easy fix once I realized what was wrong, and, yup, I had pretty much the same “WTF?!” experience as you just did.   (Followed rather immediately by, “Oh...   well, duh...”)

Re: improper json response
by remiah (Hermit) on Mar 17, 2012 at 11:12 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://960010]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2024-04-23 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found