guyboertje/jrjackson — pull request #30 by headius (2014-09-11 00:28:42+00:00)
Title: Special-case Struct to maintain to_a behavior in Ruby 2.0+ compat.

The current serialization logic does not handle Struct instances specially, allowing them to fall into the "unknown" serializer. That logic tries to call `to_h`, `to_hash`, `to_a`, etc in order on the given object until one of the coercions work. This allowed structs to serialize as an array of their values.

However, Ruby 2.0 (supported by JRuby 9k) added to_h to Struct, to get a hash representation of both keys and values. As a result, the jrjackson serializer now hits to_h for structs and inserts a hash into the resulting json instead of an array.

Assuming you want to keep the array behavior, this patch special-cases RubyStruct to always use to_a. If you aren't concerned about dispatching, it could call RubyStruct.to_a statically. If this is not the right fix, feel free to reject PR :-)