Update modX::toJSON to support not only arrays