diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java index 82f7f20a0..0cb9c10ef 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java @@ -11,6 +11,7 @@ import com.facebook.jni.HybridData; import com.facebook.proguard.annotations.DoNotStrip; import java.util.HashMap; +import java.util.Iterator; import com.facebook.infer.annotation.Assertions; import javax.annotation.Nullable; @@ -248,7 +249,31 @@ public class ReadableNativeMap extends NativeMap implements ReadableMap { } return hashMap; } - return getLocalMap(); + + // we can almost just return getLocalMap(), but we need to convert nested arrays and maps to the + // correct types first + HashMap hashMap = new HashMap<>(getLocalMap()); + Iterator iterator = hashMap.keySet().iterator(); + + while (iterator.hasNext()) { + String key = (String) iterator.next(); + switch (getType(key)) { + case Null: + case Boolean: + case Number: + case String: + break; + case Map: + hashMap.put(key, Assertions.assertNotNull(getMap(key)).toHashMap()); + break; + case Array: + hashMap.put(key, Assertions.assertNotNull(getArray(key)).toArrayList()); + break; + default: + throw new IllegalArgumentException("Could not convert object with key: " + key + "."); + } + } + return hashMap; } /**