Guest User

Untitled

a guest
Jan 19th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. package org.acme;
  2.  
  3. class ClassA
  4. {
  5. String a;
  6. String b;
  7. }
  8.  
  9. interface Entity {}
  10. static class Person implements Entity {}
  11.  
  12. Genson genson = new Genson.Builder().setWithClassMetadata(true).create();
  13. // json will be equal to {"@class":"my.package.Person"}
  14. String json = genson.serialize(new Person());
  15.  
  16. // and now Genson is able to deserialize it back to Person using the information
  17. // in the Json Object
  18. Person person = (Person) genson.deserialize(json, Entity.class);
  19.  
  20. Genson genson = new Genson.Builder().addAlias("person", Person.class).create();
  21. // json value is {"@class": "person"}
  22. String json = genson.serialize(new Person());
Add Comment
Please, Sign In to add comment