-3

Below is the output of my code...

System.out.println(CompanyStructure.get());

 Output:    [com.some.spf.b2bac.facilit.api.parameter.GetkingResult$king@2357662d, com.some.spf.b2bac.facilit.api.parameter.GetkingResult$king@633ced71, com.some.spf.b2bac.facilit.api.parameter.GetkingResult$king@312aac03]

I tried to convert to json string.

jsonString = CommonUtil.convertFromEntityToJsonStr(CompanyStructure.get());

System.out.println(jsonString);

Output:[{"customerId":"1"},{"customerId":"2"},{"customerId":"3"}];

I want to fetch all names with the ids 1,2,3 through sql iam using postgresql. how do i fix this?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Your Friend
  • 1,119
  • 3
  • 12
  • 27

1 Answers1

1

You get the Object representation of object. To loop though the objects that get() method use a for each:

for (GetkingResult result : CompanyStructure.get()) {
    if (result.getId() == 1) // do something
}

Also you can override the toString() method of the GetkingResult object.

Community
  • 1
  • 1
Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109