Closed asarubbo closed 3 years ago
@asarubbo plot twist: that is NOT JSON!
It is print of Python dict, you are basically doing this:
python_dict = {
'a': None,
'b': 'lol'
}
print(python_dict)
{'a': None, 'b': 'lol'}
And that is expected... if you want JSON on stdout you must do this (convert python dict into JSON string):
import json
python_dict = {
'a': None,
'b': 'lol'
}
print(json.dumps(python_dict))
{"a": null, "b": "lol"}
So in your example code:
#!/usr/bin/python3.8
from huawei_lte_api.Client import Client
from huawei_lte_api.AuthorizedConnection import AuthorizedConnection
import sys
import json
connection = AuthorizedConnection('http://admin:pass@192.168.8.1/')
client = Client(connection)
print(json.dumps(client.sms.get_sms_list()))
client.user.logout()
Well i think this is solved... closing
Hi, I'm not a python developer so I didn't know python dict :)
Thanks, it works like a charm!
I got:
Json validator says that it is invalid, infact I can't parse it with jq.
1) 'Sca': None should be 'Sca': 'None'
( missing single quote)
2) All strings should have double quote.
I can get a valid json with the following ( just for example ):