{"comment":{"created_at":"2011-10-10T18:30:49Z","body":"The convention is called \"Badgerfish\" and is absolutely insane, I agree.  And I don't think any code would be broken by fixing it, since the one-element list is just a special case of the n-element list.","updated_at":"2011-10-10T18:30:49Z","url":"https://api.github.com/repos/openplans/OpenTripPlanner/issues/comments/2350588","id":2350588,"user":{"avatar_url":"https://secure.gravatar.com/avatar/7af0a4685e93e44ffcd2935fa31ff1c4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/novalis","id":77003,"login":"novalis"}},"action":"created","issue":{"number":532,"created_at":"2011-10-10T09:14:00Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"When benchmarking OTP I want to parse each response to count the number of itineraries it includes. There are two things that make this more complicated than it should be:\r\n\r\n1. The list of itineraries is serialized as a JSON array of objects when it contains more than one itinerary, but as a JSON object when it contains only one itinerary.\r\n\r\n2. When it is serialized as an array, the 'itineraries' key is associated with an object containing a single 'itinerary' key, which in turn maps to an array of itineraries.\r\n\r\n\"itineraries\": { \"itinerary\" : { the elements of a single itinerary } }\r\nvs \r\n\"itineraries\": { \"itinerary\" : [{...},{...},{...}] }\r\n\r\nsee:\r\nhttp://stackoverflow.com/questions/5641430/jaxb-single-element-in-array\r\nhttp://stackoverflow.com/questions/5801766/json-data-problem\r\nhttp://stackoverflow.com/questions/3946102/jaxb-json-force-brackets-on-arrays\r\nhttp://stackoverflow.com/questions/2199453/how-can-i-customize-serialization-of-a-list-of-jaxb-objects-to-json\r\n\r\nApparently this is considered a feature, and the solution is to switch to another JSON library (Jackson) that does what you would expect.\r\n\r\nI just set the accept header to application/xml and parse that for now, but we may want to address this eventually.","comments":1,"title":"odd arrays in json response","updated_at":"2011-10-10T18:30:49Z","url":"https://api.github.com/repos/openplans/OpenTripPlanner/issues/532","id":1861920,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/aa89cac4eb961da882e29b31fac16ab9?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/andrewbyrd","id":112871,"login":"andrewbyrd"},"html_url":"https://github.com/openplans/OpenTripPlanner/issues/532","labels":[{"name":"api","url":"https://api.github.com/repos/openplans/OpenTripPlanner/labels/api","color":"aaaabb"},{"name":"webapp","url":"https://api.github.com/repos/openplans/OpenTripPlanner/labels/webapp","color":"e102d8"}],"state":"open"},"legacy":{"issue_id":1861920,"comment_id":2350588}}