You Java doesn't match the JSON, and the error message is telling you that you're trying to parse an object rather than an array (although, the code you show using Gson wouldn't throw the exception). I'm also not sure what the thing you show under your JSON is, because it bears no resemblance to the JSON either.
Your JSON is an array. That array contains an object (presumably you're expecting it to have many of these, but as-is it shows one). That object has two fields; customerDetails
and shippingDetails
that each hold another object.
Your Orders
class would need to be:
public class Orders {
private CustomerDetail customerDetails;
private Shipping shippingDetails;
}
(and given that it looks like that's a single order, I'd drop the plural and name the class Order
)
You can then parse that JSON with Gson via:
Orders[] orders = new Gson().fromJson(myJson, Orders[].class);