- Let's create a User class to support our operations:
public class User { private String name; private String email; private Integer[] profiles; public User(String name, String email, Integer[] profiles) { this.name = name; this.email = email; this.profiles = profiles; } //DO NOT FORGET TO IMPLEMENT THE GETTERS AND SETTERS}
- Then a UserView class to do all the JSON operations:
@ViewScoped@Namedpublic class UserView implements Serializable{ private static final JsonBuilderFactory BUILDERFACTORY = Json.createBuilderFactory(null); private final Jsonb jsonbBuilder = JsonbBuilder.create(); private String fromArray; private String fromStructure; private String fromUser; private String fromJpointer; public void loadUserJson(){ ...