Question:
How do I use these 2 objects Object1 and Object2 in my java?
Answer: Quoted from here:
"The following argument types are supported for methods annotated with @ReactMethod and they directly map to their JavaScript equivalents"
Boolean -> Bool
Integer -> Number
Double -> Number
Float -> Number
String -> String
Callback -> function
ReadableMap -> Object
ReadableArray -> Array
React Native is converting the javascript object into a ReadableMap.
So instead of expecting an Object in the native module, You should implement the method like this:
@ReactMethod
public void processData(final ReadableMap obj1, final ReadableMap obj2) {
// Parse the ReadableMap using the available interface methods
}
Those are the available methods in the ReadableMap interface: Source
public interface ReadableMap {
boolean hasKey(String name);
boolean isNull(String name);
boolean getBoolean(String name);
double getDouble(String name);
int getInt(String name);
String getString(String name);
ReadableArray getArray(String name);
ReadableMap getMap(String name);
Dynamic getDynamic(String name);
ReadableType getType(String name);
ReadableMapKeySetIterator keySetIterator();
HashMap<String, Object> toHashMap();
}
UPDATE
Following the example object you posted, you can parse your data like this:
ReadableMap data1 = obj1.getMap("data1");
String id = data1.getString("id");
String name = data1.getString("name");
// And so on...
ReadableMap details = obj1.getMap("details");
String detailId = details.getString("detailId");
int counter = details.getInt("counter");
// And so on...