Update modX::toJSON to support not only arrays

I think `modX::toJSON` should be not limited to the arrays only as the `Services_JSON::encode` and `json_encode` support not only arrays as input.