Add type check in method json_to_hash

The variable being sent to the json_to_hash method seems to already be a Hash and therefore the call to JSON.parse() raises the following error

TypeError: can't convert Hash into String

This pull request check if the variable is a Hash and returns it otherwise it'll attempt to call JSON.parse.