0

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?

António Ribeiro
  • 4,129
  • 5
  • 32
  • 49
Saurabh Chaturvedi
  • 2,028
  • 2
  • 18
  • 39
  • 2
    It might be easier to help if you were to post a [MCVE](http://www.stackoverflow.com/help/mcve) which reproduces this issue. – Andy Turner Feb 08 '16 at 11:19

1 Answers1

1

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.

randers
  • 5,031
  • 5
  • 37
  • 64