I'm acctually having trouble with an json string an python. I've written a script that use find-my-iphone python module this module give me this string at the output
{u'locationType': u'', u'altitude': 0.0, u'locationFinished': True, u'longitude': 7.340714223689717, u'positionType': u'GPS', u'floorLevel': 0, u'timeStamp': 1497518502892L, u'latitude': 47.81268700030429, u'isOld': False, u'isInaccurate': False, u'verticalAccuracy': 0.0, u'horizontalAccuracy': 50.0}
After a bit of prosesing with:
loc = api.devices[deviceID].location()
locstr = str(loc).replace("u'",'"').replace("'",'"') #.replace("}","")
I obtain a string that look like this:
{"locationType": "", "altitude": 0.0, "locationFinished": False, "longitude": 7.340450948111099, "positionType": "GPS", "floorLevel": 0, "timeStamp": 1497518436368L, "latitude": 47.81275740829093, "isOld": False, "isInaccurate": False, "verticalAccuracy": 0.0, "horizontalAccuracy": 100.0}
There is my code: `
from pyicloud import PyiCloudService
from geopy.distance import vincenty
import json
import sys
api = PyiCloudService('*****.*****@free.fr','******')
deviceID = u"Qo+Jyvct3IIl7N3MXrz6LfDvm8qjDCHjkedOvse1mhzWf1sikvSFQOHYVNSUzmWV" # Needed
deviceNAME = "<AppleDevice(iPhone 5s: David Smartphone)>" # Just an help
api.devices[deviceID].location()
api.devices[deviceID].status()
loc = api.devices[deviceID].location()
locstr = str(loc).replace("u'",'"').replace("'",'"') #.replace("}","")
But when I try to use
json.loads(locstr)
Python give me :
Traceback (most recent call last): File "distancePAPA.py", line 19, in t = json.loads(locstr) File "/usr/lib/python2.7/json/init.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded
I don't really know what I did wrong so I'am asking fo help
PS1: I just really need gps coordinate PS2: I'm french so sorry for mistake.