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.
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?
On Wednesday, 06 June, 2012 at 15:00, ERIK D wrote:
> 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 received this message because you are subscribed to the Google Groups "reddit-dev" group.
> To post to this group, send email to reddit-dev@googlegroups.com (mailto:reddit-dev@googlegroups.com).
> To unsubscribe from this group, send email to reddit-dev+unsubscribe@googlegroups.com (mailto:reddit-dev+unsubscribe@googlegroups.com).
> For more options, visit this group at http://groups.google.com/group/reddit-dev?hl=en.
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.
On Wednesday, June 6, 2012 6:59:21 PM UTC-4, David King wrote:
> 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?
> On Wednesday, 06 June, 2012 at 15:00, ERIK D wrote:
> > 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 received this message because you are subscribed to the Google > Groups "reddit-dev" group. > > To post to this group, send email to reddit-dev@googlegroups.com(mailto: > reddit-dev@googlegroups.com). > > To unsubscribe from this group, send email to > reddit-dev+unsubscribe@googlegroups.com (mailto: > reddit-dev+unsubscribe@googlegroups.com). > > For more options, visit this group at > http://groups.google.com/group/reddit-dev?hl=en.
> 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
On Thursday, June 7, 2012 9:56:42 PM UTC-4, David King wrote:
> > 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