Use the new standard javax JSON serializes POJOs into JSON
                                        
                    •
                    Java                                    
                I like the idea of using JSON serialization standard in Java, javax JSON is a big step forward. You can create an object graph like this:
JsonObject jsonObject3 =
Json.createObjectBuilder()
.add("name","Ersin")
.add("surname","Çetinkaya")
.add("age",25)
.add("address",Json.createObjectBuilder()
          .add("city","Bursa")
          .add("country","Türkiye")
          .add("zipCode","33444"))
.add("phones",Json.createArrayBuilder()
                  .add("234234242")
                  .add("345345354"))
.build();
That's it, but how do you serialize POJOs or simple Java objects (such as maps) directly into JSON? As I did in gson:
Person person = new Person(); String jsonStr = new Gson().toJson(person);
How do I do this using the new standard API?
Solution
The Java API for JSON processing (JSR - 353) does not include object binding This will be covered in a separate JSR
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        