I have object like the below
data class CallInfo (@SerializedName("callStatus") val callStatus : String,@SerializedName("callType") val callType : String,@SerializedName("callDirection")val callDirection: String,@SerializedName("callMode") val callMode : String,@SerializedName("users") val users : List<Users>)
And i'm trying to send this object to react-native by Emit method
@ReactModule(name = RoomModule.NAME)public class RoomModule extends ReactContextBaseJavaModule {public static final String NAME = "RoomModule";public RoomModule(@NonNull ReactApplicationContext reactContext) { super(reactContext);} public static void startCall(){ Random random = new Random(); String randomString = String.valueOf(random.nextInt()).replace("-", ""); ArrayList<Users> usersArrayList=new ArrayList<>(); usersArrayList.add(new Users("Thiyaga1","https://thiyagadude.com/api/v1/media/xSoIkb0XAh1590760167030")); usersArrayList.add(new Users("Thiyaga2","https://thiyagadude.com/api/v1/media/xSoIkb0XAh1590760167030")); CallInfo callInfo=new CallInfo("calling","audio","outgoing","onetoone",usersArrayList); @Nullable Bundle launchOptions = ConstructBundle.INSTANCE.getCallUsersJsonObject(callInfo); WritableMap initialProps = Arguments.makeNativeMap(launchOptions); WritableNativeMap appParams = new WritableNativeMap(); appParams.putMap("initialProps", initialProps); ReactInstanceManagerHolder.emitEvent("com.thiyaga.react:features/connection_service#startCall",appParams);}}
ConstructBundle.kt
Object ConstructBundle{ private fun getCallUsersJsonObject(userInfo:CallInfo):Bundle? { val bundle = Bundle() bundle.putString("id", userInfo.id) bundle.putString("name", userInfo.name) bundle.putParcelableArrayList("users", getUsersObject(userInfo.users) ) return bundle;}private fun getUsersObject(users: List<Users>): ArrayList<Bundle> { val array = ArrayList<Bundle>() for (user in users) { val jo = Bundle() jo.putString("name", user.name) jo.putString("avatar", user.avatar) array.add(jo) } return array}}
i should be getting the map as the below..
{"initialProps": { "callStatus": "calling","callDirection": "outgoing","callType": "audio", "callMode": "onetoone", "users": [ {"name": "Thiyaga1","avatar": "https://thiyagadude.com/api/v1/media/xSoIkb0XAh1590760167030" }, {"name": "Thiyaga2","avatar": "https://thiyagadude.com/api/v1/media/xSoIkb0XAh1590760167030 } ]}}
but instead i'm getting like the below
{"initialProps": { "callStatus": "calling","callDirection": "outgoing","callType": "audio", "callMode": "onetoone", "users": [[Object], [Object]]}}
the issue here is that if i send the data without assigning to "initialProps" key value i could able to send the whole data...
{ "callStatus": "calling","callDirection": "outgoing","callType": "audio", "callMode": "onetoone", "users": [ {"name": "Thiyaga1","avatar": "https://thiyagadude.com/api/v1/media/xSoIkb0XAh1590760167030" }, {"name": "Thiyaga2","avatar": "https://thiyagadude.com/api/v1/media/xSoIkb0XAh1590760167030 } ]}
thank in advance for everyone who is answering.. hope community helps me from my nightmare..