colorado-code-for-communities / androidtracks

OpenBike for Android
http://openbike.co
GNU General Public License v3.0
1 stars 2 forks source link

Remove quotes from Coords value #9

Closed MikeLockz closed 11 years ago

MikeLockz commented 11 years ago

Currently the value for the Coord key is a quoted JSON list of coordinates. This is causing parsing issues on the backend. The quotes need to be removed from the very beginning and very end of the value to make properly formed JSON.

MikeLockz commented 11 years ago

{"_id":"1367991617509_966","_rev":"1-4240eee0e1f741771099d0862c999b4c","coords":

--->"<-----REMOVE THIS QUOTE!! {\"2013-05-07 23:40:02\":{\"vac\":9,\"lon\":-104.94871,\"rec\":\"2013-05-07 23:40:02\",\"spd\":0,\"alt\":1623.5,\"lat\":39.682957,\"hac\":9},\"2013-05-07 23:39:59\":{\"vac\":11,\"lon\":-104.948694,\"rec\":\"2013-05-07 23:39:59\",\"spd\":0,\"alt\":1624.699951171875,\"lat\":39.682935,\"hac\":11},\"2013-05-07 23:39:57\":{\"vac\":13,\"lon\":-104.948697,\"rec\":\"2013-05-07 23:39:57\",\"spd\":0,\"alt\":1620.9000244140625,\"lat\":39.682954,\"hac\":13},\"2013-05-07 23:40:00\":{\"vac\":10,\"lon\":-104.9487,\"rec\":\"2013-05-07 23:40:00\",\"spd\":0,\"alt\":1624.9000244140625,\"lat\":39.682942,\"hac\":10},\"2013-05-07 23:39:55\":{\"vac\":17,\"lon\":-104.9487,\"rec\":\"2013-05-07 23:39:55\",\"spd\":0,\"alt\":1624.699951171875,\"lat\":39.682952,\"hac\":17}}","user":"{\"gender\":\"M\",\"workZIP\":\"80202\",\"email\":\"mlockwitz@gmail.com\",\"cyclingFreq\":2,\"schoolZIP\":\"\",\"age\":\"28\",\"homeZIP\":\"80210\"}","device":"androidDeviceId-f96372616546f1b5","notes":"","purpose":"Social","start":"2013-05-07 23:39:50","end":"2013-05-07 23:40:02","ease":"5.0","safety":"0.5","convenience":"2.5","version":"2"}

MikeLockz commented 11 years ago

Part of TripUploader.java around line 208 nameValuePairs.add(new BasicNameValuePair("coords", coords.toString()));

apryce commented 11 years ago

I'll take a look at this at the hack. It seems like something small enough for me to start on.

apryce commented 11 years ago

It looks like the issue is that we are putting everything in a list of key-value pairs through List. What we actually want is for them to be part of a larger json object. See this post for nesting JSON objects. http://stackoverflow.com/questions/9231103/how-to-nest-objects-when-building-json-with-jsonobject

We also believe that the quotes shouldn't be removed, but hard brackets instead. This is achieved with a JSONArray.

apryce commented 11 years ago

Mike says it's fixed!