How to do it...

  1. 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}
  1. 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(){ ...

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.