json { "mappingRule": "Annotation", "namingStrategy": "CamelCase" } import com.jsonty.JsonProperty; public class Person { @JsonProperty private String name; @JsonProperty private int age; @JsonProperty("email_address") private String emailAddress; } import com.jsonty.JsonObject; import com.jsonty.JsonTy; public class JsonExample { public static void main(String[] args) { Person person = new Person(); person.setName("Alice"); person.setAge(25); person.setEmailAddress("alice@example.com"); JsonObject json = JsonTy.toJson(person); String jsonString = json.toString(); System.out.println(jsonString); Person parsedPerson = JsonTy.fromJson(jsonString, Person.class); System.out.println(parsedPerson.getName()); System.out.println(parsedPerson.getAge()); System.out.println(parsedPerson.getEmailAddress()); } } json { "mappingRule": "Field", "namingStrategy": "CamelCase" } import com.jsonty.JsonTy; public class Person { private String name; private int age; private String emailAddress; }


上一篇:
下一篇:
切换中文