This example demonstrates how to use JSONB with resource classes.
The mapping of the URI path space is presented in the following table:
URI path | Resource class | HTTP methods |
---|---|---|
/jsonb/cats/one | JsonbResource | GET |
/jsonb/cats/all | JsonbResource | GET |
/jsonb/cats/add | JsonbResource | POST |
/jsonb/cats/addAll | JsonbResource | POST |
Run the example as follows:
mvn clean compile exec:java
This deploys the example using Grizzly container. You can access the application at:
or you can post an xml entity:
curl -v -X POST http://localhost:8080/json-binding-webapp/cats/add -H “Content-Type:application/json” -d ' {“color”:“white”,“sort”:“maine coon”,“catName”:“Darwin”, “domesticated”:“true”}'
You can also use the built war file to deploy the app to a container of your choice.