android - Viewing variables within a java object in the logs -


i have simple wrapper class thats displayed below:

public class embedfoods {      private collection<food> foods;      public collection<food> getfoods() {         return foods;     }      public void setfoods(collection<foods> foods) {         this.foods = foods;     } }  public class food {      private string nutrition;     private string calories;     private string peanuts;      etc...  } 

i list of "food" embedfoods class calling api returns json string , use robospice spring android populate embedfoods automatically.

now, view object embedfoods in human-readable format, preferably json.

if go log.e("embedfoods", embedfoods.tostring());, returns:

e/embedfoods [lmodel.food;@25ef9bbb

i can see model inside embedfood class, cannot see variables comprises of. hoping see json string shows variable of java object printed in logs.

how can view variables set within embedfood class other debugging line in embedfood set in app?

well way can done overriding tostring method display correct values want see.

something

@override public string tostring() {     foods[] foods = collection.toarray();      string words = "[";     (int = 0; < foods.length; i++) {         words = words + "{" + foods.nutrition + foods.etc + "}"     }     words = words + "]"     return words; } 

in embed foods.


Comments