How can use reflection to get the property names and values from a POJO?

后端 未结 2 1578
小蘑菇
小蘑菇 2021-01-18 03:51

So I\'m writing an \"POJO to JSON\" converter. I want to be able to pass in a List object and convert to JSON.

Hopefully this will make sense<

2条回答
  •  独厮守ぢ
    2021-01-18 04:12

    Instead of kls.getfields you could need to use kls.getDeclaredFields() . And if Jason object is your concern I had recommend you a Jackson Codhaus library . In which you can get or set JsonString from your POJO... HTH

提交回复
热议问题