Fixed getting null as result when server returns objects

When the response is a object, the utf8_decode returns a null object. According to the spec, the result could be anything sent by the server.
I have added a small check to check whether its a string.