added flexability to json parsing and fixed closing hang in json rpc connection