I was trying to read and convert a JSON file to an array but getting null values from the array after reading the JSON file. I am using the default constructor for my Ship
Your Gson mapping does not match the given JSON. By default, Gson maps JSON properties to their appropriate fields in the target mapping by exact name. Take a look at:
"idmessage":"27301"
and
private String IdMessage
The property name case and the field name case do not match. What you need is map your JSON correctly. Either:
private String idmessage
or by overriding the name match (and that's more appropriate for the Java naming conventions):
@SerializedName("idmessage")
private String idMessage;
Note one field per line. This is required in order to annotated each field separately. Or, if possible, use camelCase both in Java and JSON.