Fix invalid serialization of array with empty object

Try to fixed issue with json serialization  of array with empty object.
It was serialized like `{'0': {}}` and it should be serialized as `[{}]` this PR should fix it without break all other behavior.

Fix issue #277 related with #104

Rely on changes done in #292
these changes are not related to this PR IMO, so they should not be included in it