Properly cast json to array.

See http://codepad.org/CJy32qQD. The current approach does not remove all the objects.