daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Jan 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top