Home Ask Login Register

Developers Planet

Your answer is one click away!

codechat February 2016

Not having a getter method in POJO does not set the values via setter method

I am using org.json library for JSON parsing. I have experienced that when I have two methods say getName() and setName() and if I comment the getter method in my POJO class, the setter method also does not work .

But if i don't, it works. Why this happens? Can't we just set the value in POJO and convert to JSON string?


RAnders00 February 2016

Can't we just set the value in the POJO and convert to a JSON string?

If you comment out the getter method, the JSON library will no longer serialize the property, because it has no way to get the property.

Post Status

Asked in February 2016
Viewed 3,134 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life