Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

JSON Problems

by nathanlong85 (Initiate)
on Oct 18, 2012 at 13:27 UTC ( #999734=perlquestion: print w/replies, xml ) Need Help??
nathanlong85 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm having some problems interacting with a JSON API and I'm pretty much out of ideas on where to go from here. It's kind of hard to post examples because I'm not really able to share the information that I'm trying to send...

Anyway, the problem is this: whenever I try to send a character like or any non-US characters I get an error back saying that my JSON is unprocessable. If I try the exact same string via curl though from the command-line it's fine, no issues. I'm wondering if Perl is somehow having problems with the encoding... I'm just using LWP::UserAgent to send my json strings and it works for any entries that don't have non-US characters. I know this is kind of vague, I just can't be too specific... maybe somebody has experienced something similar to this before too? Any help would be greatly appreciated!

One odd thing is that if I do a Data::Dumper on my LWP::UserAgent object after sending my json request, if I check out the content of my request it looks just fine... I can literally copy and paste the json string from my request dump into curl and it works


Replies are listed 'Best First'.
Re: JSON Problems
by Anonymous Monk on Oct 18, 2012 at 13:59 UTC
      Looks like encode/decode fixed my problem. I had assumed since the input creating my json string was already coming from a source using UTF-8 and I was sending to a destination using UTF-8 that it wouldn't be an issue... thanks for that link, it was really helpful!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://999734]
Approved by Corion
Front-paged by Old_Gray_Bear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2018-02-22 05:20 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (288 votes). Check out past polls.