Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

I'm trying to create an R API. Here's some basic code for processing JSON:

library(rjson)
fromJSON(readLines("http://api.stackoverflow.com/0.9/stats/", warn=F))

As I look into this, the output of readLines looks very strange:

[1] "\037‹\b"                                                                                                                                                                                                                                                                                         
[2] "\030\002úØÛy°óé½\036„iµXäË–[<üt—Zu[\\VmÎHî=ÜÛݹ×ýz’Í.äûû÷>ý´\a\177Ýh÷\017îÝÛÙwßÚáÿþ«¼þý\027ÅrÝæÔlgüÀëA±\017›ìŽï{M¤û.\020\037�Ë\"¿’\006³ì\032„Úß9¸ÿ`¼ç÷³*~ÿKêˆð¡\006v¦ð²ýô£�ñÃ�ì+ôU�_\026滽�]êt¼·?ÞûÈ4ù%\016~S0^>àe¶ÀG\037½n³éÛôKê缬®‚\016Êê¢úý×u‰fó¶]=º{·aΚŽ—y{·©î\026‹‹»h5^-/‚W1 |9[UŲõ^§�Ç"
[3] ":¬´¿1M\177ð\"0íö¹ñ…YÞLëbÕ*!~â\027\036§çU�®êê¢ÎˆµhòýæÅ´Zn\036S¶Z•ùv[­§óm´î�"                                                                                                                                                                                                                      
[4] "Í™t˪^d¥£·üÂ?¾ÿ\033'¿$ù\177"  

Should I be using some particular kind of encoding?

share|improve this question
add comment

1 Answer 1

up vote 8 down vote accepted

All api results are gzipped.

So what you are looking at is a gzipped binary blob.

Simply decompress using a gzip implementation in R.

share|improve this answer
    
This is exactly right. What you have there is gzip'ed data. –  Nathan Osman Jun 27 '10 at 16:12
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .