4 ms·
I note a comment in your code that "Twitter sends malformed JSON, with top-level array. Workaround: put it under 'tweets'." As I understand it, a top-level ar
by gcampbell 17y ago
I note a comment in your code that "Twitter sends malformed JSON, with top-level array. Workaround: put it under 'tweets'." As I understand it, a top-level array is perfectly legal JSON (see http://www.ietf.org/rfc/rfc4627 http://www.ietf.org/rfc/rfc4627 - "A JSON text is a serialized object or array."). Are there other problems with Twitter's JSON, or does Go's JSON implementation fail to support top-level arrays?
- dchest 17y agoAh. Someone at #go-nuts said it wasn't valid, so I made the change and it worked. If it's valid, than yes, it must be a bug in Go's json package. Edited the comment, filed a bug report (http://code.google.com/p/go/issues/detail?id=114 http://code.google.com/p/go/issues/detail?id=114). Thanks!
- gcampbell 17y agoAs a note, top-level JSON arrays have been demonstrated to have some security problems in web browsers when delivered via GET requests; see http://haacked.com/archive/2009/06/25/json-hijacking.aspx http://haacked.com/archive/2009/06/25/json-hijacking.aspx for more. (This isn't relevant for JSON-as-interchange-format in other contexts, of course).