Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Returning large JSON responses and PHP
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ERIK D  
View profile  
 More options Jun 6 2012, 6:00 pm
From: ERIK D <erik.dobe...@gmail.com>
Date: Wed, 6 Jun 2012 15:00:54 -0700 (PDT)
Local: Wed, Jun 6 2012 6:00 pm
Subject: Returning large JSON responses and PHP
Sorry if this is a repost. This was very frustrating for me. If you do
not supply the 'limit' switch to a query and allow the default
response, the payload delivered can actually break php's
json_decode().

For example, I tried to request

   "/search/.json?q=apple"

and json_decode chokes and dies on that, always returning malformed
JSON.

If you change the request to

   "/search/.json?q=apple&limit=1"

and so on, the payload parses fine. The limit switch should be on the
search FAQ. Even devs will look there first since it's the first thing
google gives up. I thought it was unlikely that reddit was returning
bad JSON and sure enough, it isn't.

I hope this helps someone.

Erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David King  
View profile  
 More options Jun 6 2012, 6:59 pm
From: David King <dk...@ketralnis.com>
Date: Wed, 6 Jun 2012 15:59:21 -0700
Local: Wed, Jun 6 2012 6:59 pm
Subject: Re: [reddit-dev] Returning large JSON responses and PHP
This sounds really odd, can you find out what value of `limit` causes it to break for you? The default is 25 so can you try the integers smaller than that?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik.dobe...@gmail.com  
View profile  
 More options Jun 7 2012, 4:03 pm
From: erik.dobe...@gmail.com
Date: Thu, 7 Jun 2012 13:03:11 -0700 (PDT)
Local: Thurs, Jun 7 2012 4:03 pm
Subject: Re: [reddit-dev] Returning large JSON responses and PHP

David,

Six is the largest limit I can supply without it breaking. I would imagine
it also depends on the query and the posts it returns, but (for example)
searching for "apple" I can not do more than 6. If you look at some of the
online json parsers that are php based, they break too if you copy and
paste the json.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David King  
View profile  
 More options Jun 7 2012, 9:56 pm
From: David King <dk...@ketralnis.com>
Date: Thu, 7 Jun 2012 18:56:42 -0700
Local: Thurs, Jun 7 2012 9:56 pm
Subject: Re: [reddit-dev] Returning large JSON responses and PHP

> Six is the largest limit I can supply without it breaking. I would imagine it also depends on the query and the posts it returns, but (for example) searching for "apple" I can not do more than 6. If you look at some of the online json parsers that are php based, they break too if you copy and paste the json.

Wow, that's not much data at all, and not an obvious memory boundary where size should be an issue

$ curl 'http://www.reddit.com/?limit=6' | wc -c
73684
$ curl 'http://www.reddit.com/?limit=7' | wc -c
75756

Sounds like a PHP problem to me.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik.dobe...@gmail.com  
View profile  
 More options Jun 8 2012, 10:17 pm
From: erik.dobe...@gmail.com
Date: Fri, 8 Jun 2012 19:17:30 -0700 (PDT)
Local: Fri, Jun 8 2012 10:17 pm
Subject: Re: [reddit-dev] Returning large JSON responses and PHP

I agree. Everything about how it behaved seemed like it was a problem in
php. I noticed the same issue in size differences (or lack thereof).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions Older topic »