ZF-9521: Encoding array of objects implementing toJson() method

Description

It would be much more convenient if the Zend_Json could properly encode array of objects having toJson() method. I wrote just a few additional lines to have this working locally. It's just all about DRY.

Comments

Attached patch with possible implementation of the requested feature + unit test

I've reviewed the patch and confirm it operates as intended. Recommend committing to trunk (need to check with Matthew on adding to release branch as it adds to the API). Please ensure a ZF2 git pull request including matching changes is issued for ZF2 before resolving.

Committed to trunk in r24424

Fix merged into ZF2 via PR-364

Was fixed in 1.12.0 @ r24424