@@ -234,7 +234,7 @@ public Optional<JSONObject> getData() {
234234 return Optional .empty ();
235235 }
236236
237- JSONObject json = parseBundleToJson (intent .getExtras ());
237+ JSONObject json = parseBundleToJson (null , intent .getExtras ());
238238 if (json == null ) {
239239 return Optional .empty ();
240240 }
@@ -244,13 +244,13 @@ public Optional<JSONObject> getData() {
244244
245245 //> PRIVATE
246246
247- private JSONObject parseBundleToJson (Bundle bundle ) {
247+ private JSONObject parseBundleToJson (String parentKey , Bundle bundle ) {
248248 try {
249249 JSONObject json = new JSONObject ();
250250 bundle
251251 .keySet ()
252252 .iterator ()
253- .forEachRemaining (key -> setValueInJson (key , json , bundle ));
253+ .forEachRemaining (key -> setValueInJson (parentKey , key , json , bundle ));
254254 return json ;
255255
256256 } catch (Exception exception ) {
@@ -260,26 +260,28 @@ private JSONObject parseBundleToJson(Bundle bundle) {
260260 return null ;
261261 }
262262
263- private void setValueInJson (String key , JSONObject json , Bundle bundle ) {
263+ private void setValueInJson (String parentKey , String childKey , JSONObject json , Bundle bundle ) {
264+ String key = ("detectedRdt" .equals (parentKey ) && "concerns" .equals (childKey ))
265+ ? "detected_rdt_concerns"
266+ : childKey ;
264267 try {
265- Object value = bundle .get (key );
268+ Object value = bundle .get (childKey );
266269
267270 if (value instanceof Bitmap ) {
268271 json .put (key , parseBitmapImageToBase64 ((Bitmap ) value ));
269272 return ;
270273 }
271274
272275 if (value instanceof Bundle ) {
273- json .put (key , parseBundleToJson ((Bundle ) value ));
276+ json .put (key , parseBundleToJson (key , (Bundle ) value ));
274277 return ;
275278 }
276279
277280 if (isBundleList (value )) {
278281 JSONArray jsonArray = ((List <Bundle >) value )
279282 .stream ()
280- .map (this :: parseBundleToJson )
283+ .map (val -> this . parseBundleToJson ( key , val ) )
281284 .collect (Collector .of (JSONArray ::new , JSONArray ::put , JSONArray ::put ));
282-
283285 json .put (key , jsonArray );
284286 return ;
285287 }
0 commit comments