From: Marcin Masternak Date: Wed, 1 Jun 2016 11:47:24 +0000 (+0200) Subject: [my-place] Output JSON places fix. X-Git-Tag: submit/tizen/20160622.045445~1^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F01%2F72601%2F1;p=platform%2Fcore%2Fcontext%2Fcontext-provider.git [my-place] Output JSON places fix. Change-Id: I66fd171c20ff6a3de47ec0c342e472578384c915 Signed-off-by: Marcin Masternak --- diff --git a/src/my-place/user_places/user_places.cpp b/src/my-place/user_places/user_places.cpp index a2a129a..621a40a 100755 --- a/src/my-place/user_places/user_places.cpp +++ b/src/my-place/user_places/user_places.cpp @@ -122,17 +122,22 @@ ctx::Json ctx::UserPlaces::__composeJson(std::vector> pla placeJson.set(NULL, PLACE_CATEG_CONFIDENCE, static_cast(place->categConfidence)); placeJson.set(NULL, PLACE_NAME, place->name); if (place->locationValid) { - placeJson.set(NULL, PLACE_LOCATION_LATITUDE, static_cast(place->location.latitude)); - placeJson.set(NULL, PLACE_LOCATION_LONGITUDE, static_cast(place->location.longitude)); + ctx::Json locationJson; + locationJson.set(NULL, PLACE_LOCATION_LATITUDE, static_cast(place->location.latitude)); + locationJson.set(NULL, PLACE_LOCATION_LONGITUDE, static_cast(place->location.longitude)); + locationJson.set(NULL, PLACE_LOCATION_ACCURACY, static_cast(place->location.accuracy)); + placeJson.set(NULL, PLACE_LOCATION, locationJson); } - ctx::Json wifiApsListJson; - for (std::pair ap : place->wifiAps) { - ctx::Json wifiApJson; - wifiApJson.set(NULL, PLACE_WIFI_AP_MAC, ap.first); - wifiApJson.set(NULL, PLACE_WIFI_AP_NETWORK_NAME, ap.second); - wifiApsListJson.append(NULL, PLACE_WIFI_APS, wifiApJson); + if (place->wifiAps.size()) { + ctx::Json wifiApsListJson; + for (std::pair ap : place->wifiAps) { + ctx::Json wifiApJson; + wifiApJson.set(NULL, PLACE_WIFI_AP_MAC, ap.first); + wifiApJson.set(NULL, PLACE_WIFI_AP_NETWORK_NAME, ap.second); + wifiApsListJson.append(NULL, PLACE_WIFI_APS, wifiApJson); + } + placeJson.set(NULL, PLACE_WIFI_APS, wifiApsListJson); } - placeJson.set(NULL, PLACE_WIFI_APS, wifiApsListJson); placeJson.set(NULL, PLACE_CREATE_DATE, static_cast(place->createDate)); data.append(NULL, PLACE_DATA_READ, placeJson); }