Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to serialize Java properties to JSON

Tags:

java

json

Can I have JSON serialize properties (I mean Java bean getter and setter properties) of POJOs?

like image 205
gotch4 Avatar asked Sep 11 '26 08:09

gotch4


1 Answers

Yes. The Jackson and Jersey projects will be able to help you there. Here is an article about serializing a Java object using Jackson. Essentially, you can do

new JavaTypeMapper().writeValue(new File("out.json"), myObject);
like image 62
Jack Edmonds Avatar answered Sep 13 '26 23:09

Jack Edmonds