-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) #64
Comments
Weird; it looks like that status string decodes to: {[{"No":"1","Cfg":"1","State":"0"},{"No":"2","Cfg":"0","State":"0"},{"No":"3","Cfg":"0","State":"0"},{"No":"4","Cfg":"0","State":"0"},{"No":"5","Cfg":"0","State":"0"},{"No":"6","Cfg":"0","State":"0"},{"No":"7","Cfg":"0","State":"0"},{"No":"8","Cfg":"0","State":"0"}]} …which of course is not valid JSON. You can't start a JSON document with I guess we could detect the error, try just stripping off the |
Since we have determined that LG can return a json wrapped in curly braces, I think detecting the error is the best long term solution. You never know when other json results might come like. |
This is easily fixed by checking for such malformed json and than apply a fix at both start and end:
in client.pi#435 |
this is related to bug sampsyo#64
https://aic.lgthinq.com:46030/api/rti/rtiControl {'cmd': 'Config', 'cmdOpt': 'Get', 'value': 'DuctZone', 'deviceId': 'd27c7740-7149-11d3-80b4-7440be9deeb2', 'workId': 'a3dcce9c-af3d-1024-a8a0-cfbb0c395bb3', 'data': ''} <Response [200]> {'returnCd': '0000', 'returnMsg': 'OK', 'deviceId': 'd27c7740-7149-11d3-80b4-7440be9deeb2', 'stateCode': 'S', 'workId': 'n-a3dcce9c-af3d-1024-a8a0-cfbb0c395b', 'returnData': 'e1t7Ik5vIjoiMSIsIkNmZyI6IjEiLCJTdGF0ZSI6IjAifSx7Ik5vIjoiMiIsIkNmZyI6IjAiLCJTdGF0ZSI6IjAifSx7Ik5vIjoiMyIsIkNmZyI6IjAiLCJTdGF0ZSI6IjAifSx7Ik5vIjoiNCIsIkNmZyI6IjAiLCJTdGF0ZSI6IjAifSx7Ik5vIjoiNSIsIkNmZyI6IjAiLCJTdGF0ZSI6IjAifSx7Ik5vIjoiNiIsIkNmZyI6IjAiLCJTdGF0ZSI6IjAifSx7Ik5vIjoiNyIsIkNmZyI6IjAiLCJTdGF0ZSI6IjAifSx7Ik5vIjoiOCIsIkNmZyI6IjAiLCJTdGF0ZSI6IjAifV19', 'format': 'B64', 'deviceState': 'E', 'timestamp': 0}
Traceback (most recent call last):
File "example.py", line 230, in
main()
File "example.py", line 226, in main
example(args.country, args.language, args.cmd, args.args)
File "example.py", line 186, in example
example_command(client, cmd, args)
File "example.py", line 162, in example_command
func(client, *args)
File "example.py", line 147, in ac_config
print(ac.get_zones())
File "/Users/david/dev/unsorted/wideq/wideq/ac.py", line 196, in get_zones
return self._get_config('DuctZone')
File "/Users/david/dev/unsorted/wideq/wideq/client.py", line 440, in _get_config
return json.loads(base64.b64decode(data).decode('utf8'))
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
The text was updated successfully, but these errors were encountered: