Home » Java » java – How to push this array of objects to something that can later be pushed to WritableNativeMap?-Exceptionshub

java – How to push this array of objects to something that can later be pushed to WritableNativeMap?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have an array of objects and I would like to pass it to React-Native through the bridge but as you know I can only do it via WritableNativeMap, however, I am stuck at pushing that array to WritableNativeMap. I really need help with this!

The array:

Array of cars : [{"error":"","cars":[{"id":0,"tagid":"sdfsdfsd","plate":"ertt","sms":"sdfsdf","latitude":"55.618331","longitude":"13.010308"},{"id":1,"tagid":"ertert","plate":"TEST","sms":"34535","latitude":"55.8444","longitude":"11.841"},{"id":2,"tagid":"435345345345fh","plate":"TEST2","sms":"44534543","latitude":"55345345781","longitude":"12.16456554"}]}]


@ReactMethod
public void getLocks(Callback callback) {
    WritableNativeArray arguments = new WritableNativeArray();
    arguments.pushArray((ReadableArray) arrayCars.jsonResponse);
    callback.invoke("arr", arguments);
 }
How to&Answers: