Parsing, generating, transforming, and querying on JSON objects using JSON-P
Dealing with JSON objects is an activity that you can't avoid anymore. So if you can do it by relying on a powerful and easy to use framework—even better!
This recipe will show you how you can use JSON-P to carry out some different operations using or generating JSON objects.
Getting ready
Start by adding the Java EE dependency:
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
How to do it...
- 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...