Reputation: 1367
I'm trying to convert a json format response from a web service into an ArrayList<Stop>
object.
Before converting the json response into a java object I made sure the database is retreiving all the data in a proper manner, see the image below.
However after converting the json response and debugging the android app I realized that the value of all the integer fields has been set to zero.
The fields stopId
and journeyId
correspond to a PRIMARY_KEY
and FOREIGN_KEY
respectively in the database.
This is the snipet of code I wrote to do this.
Thanks in advance for all your help.
Upvotes: 0
Views: 518
Reputation: 4182
Try to change your model class according Camel Case Sensitive,
change stop_id
to stopId
and journey_id
to journeyId
. Or configure your Gson according your necessities:
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).create();
String jsonRepresentation = gson.toJson(someObject);
System.out.println(jsonRepresentation);
Upvotes: 1