Without discussing why such a class is useful... How would you manually encode such object?

In JSON you can have dictionaries and lists, so you cannot expect a list to have extra named attributes.

You can make your IntSeq class to have a list attribute and not extend Seq itself (and maybe provide an automatic conversion), so your JSON could look like:

{'length' : 5, 'ints' : [1, 2, 3, 4, 5]}

Related Query

More Query from same tag