Fixed missed cast on original object.

The cast option is used mostly on the server side with `GET` requests. `GET` request converts everything to strings, and the casting helps to repair types back. This patch fixes the previous implementation, that leaves the original object unchanged.