lundi 19 novembre 2018

Reflection API, cannot convert from Object to JSONArray

I have the following method:

public static void passInfoToAutoDebitService() throws Exception
 {
     AutoDebitService.init();
     String bookingDetails = getQueueBookingDetails();
     long time = System.nanoTime();
     HttpServer localServer = initiliazeAndCreateMockServer();
     localServer.start();
     Method method = AutoDebitService.class.getDeclaredMethod("parseBookingsToCheckoutXML", String.class);
     method.setAccessible(true);
     JSONArray jsonArray =  method.invoke(null, bookingDetails); //Error - Cannot convert from Object to JSONArray

     localServer.stop(0); 
 }

The above method is supposed to call method "parseBookingsToCheckoutXML" passing "bookingDetails" as parameter.

The method "parseBookingsToCheckoutXML" returns a JSONArray, but in the line I indicated in the code above, I get the error - Type mismatch: Cannot convert from Object to JSONArray.

Please help!





Aucun commentaire:

Enregistrer un commentaire