Invalid JSON


#1

This is returning invalid JSON.
https://api.twitter.com/1.1/users/lookup.json?screen_name=unitusccu

See snippet of JSON string below.

Note “Source” element.

"statuses_count": 1958,
    "lang": "en",
    "status": {
        "created_at": "Tue Oct 08 23:45:42 +0000 2013",
        "id": 387725522739789800,
        "id_str": "387725522739789824",
        "text": "@cpeiffler @Rayterrill Clifford thx for the props! Ray, all our tech/online services are top notch. Check us out! https://t.co/X0DOZOefjW",
        "source": "<a href="http: //www.tweetdeck.com" rel="nofollow">TweetDeck</a>",
        "truncated": false,
        "in_reply_to_status_id": 387639127601983500,
        "in_reply_to_status_id_str": "387639127601983490",
        "in_reply_to_user_id": 172028267,
        "in_reply_to_user_id_str": "172028267",
        "in_reply_to_screen_name": "cpeiffler",
        "geo": null,
        "coordinates": null,
        "place": null,

If you escape the URL like so, it’s valid.


"source": "<a href=\"http: //www.tweetdeck.com\" rel=\"nofollow\">TweetDeck</a>",

Is this is a known bug or do I have to work around this??


#2

Have you taken a look at the raw response from the API? It looks more like:

“source”:"\u003ca href=“http://www.tweetdeck.com” rel=“nofollow”\u003eTweetDeck\u003c/a\u003e"

What are you using to process the response? Perhaps it is being munged?


#3

Used your developer console to create the string . Pasted string in to PHP and tried to read using json_decode function.


#4

When the web-based console formats the JSON, the act of consuming it can change it. It’s really just there for demonstrative purposes. You might find it more joyful to explore the API via commandline.


#5

Makes perfect sense.

My hope is to get the data into a PHP array or object. Probably won’t get to work on this until next week, but I will let you know how I make out. In the meantime, any suggestions on methods to consume the data are welcome! (I hate re-inventing the wheel!)

PS Corey Feldman? What’s up with that?


#6

You were correct. Everything is working great. Thanks!


#7

@JohnPDX I am also facing same problem, I hope u resolved it . Please tell me the steps to resolve it.


#8

My take on this is that it’s not solved and that we shouldn’t use the developer console for anything useful. It’s just for the show. I’ve started to use Postman (a Chromium/Chrome app) for this purpose, it works fine.