Android Parse,如何检索ParseGeoPoint类型的对象

Android Parse,如何检索ParseGeoPoint类型的对象,android,parse-platform,geopoints,Android,Parse Platform,Geopoints,我有一个JSONObject,它包含一个ParseGeoPoint,我正在尝试这行代码来检索ParseGeoPoint,但是运气不好 ParseGeoPoint storeAddress = (ParseGeoPoint) shopInfo.get("coordinates"); 我通过检查其内容确保shopInfo确实具有geoPoint "coordinates":"ParseGeoPoint[30.132636,31.312510]" 我得到的错误是: java.lang.String

我有一个JSONObject,它包含一个ParseGeoPoint,我正在尝试这行代码来检索ParseGeoPoint,但是运气不好

ParseGeoPoint storeAddress = (ParseGeoPoint) shopInfo.get("coordinates");
我通过检查其内容确保shopInfo确实具有geoPoint

"coordinates":"ParseGeoPoint[30.132636,31.312510]"
我得到的错误是:

java.lang.String cannot be cast to com.parse.ParseGeoPoint

我尝试了getParseGeoPointString;但是它不能被识别为一个关键词,我该怎么办?

问题很清楚。执行shopInfo.getcoordinates行时,它只返回坐标的字符串表示形式。您尝试将字符串对象强制转换为无法工作的ParseGeoPoint对象。要使其工作,需要将ParseGeoPoint[30.132636,31.312510]表示划分为纬度和经度键和值json对。下面这行代码将起作用

    JSONObject coordinates = shopInfo.getJSONObject("coordinates");
    double latitude= coordinates.getDouble("latitude");
    double longitude= coordinates.getDouble("longitude");   
    storeAddress =new ParseGeoPoint(latitude, longitude) 
希望这有帮助。问候