Restlet parsing json request

Restlet parsing json request

I am trying to make a simple observatory app for books and stuff using restlet. Currently, I've managed some simple GETs here and there but i have a problem with POST.

I am trying to make a simple observatory app for books and stuff using restlet. Currently, I've managed some simple GETs here and there but i have a problem with POST.

To be precise, I can't access the entity's body. Here is the sample request, through Postman

{
    "isbn": "12345678909876",
    "title": "test",
    "genre": "Encyclopedias",
    "publisher": "Tzoman",
    "release": "2011-01-01",
    "language": "Foreign",
    "pages": 666,
    "cover": "Hard",
    "withdrawn": true,
    "tags": "sapiente"
}

And here is the code:

@Override
protected Representation post(Representation entity) throws ResourceException {

if (entity.getMediaType().isCompatible(MediaType.APPLICATION_JSON)) {
    //Create a new restlet form
    Form form = new Form(entity);
    System.out.println("Form start");
    System.out.println(form);
    System.out.println(form.getClass().getSimpleName());
    System.out.println("Form end");

    //Read the parameters
    String isbn = form.getFirstValue("isbn");
    System.out.println(isbn);

    try {
        System.out.println("The entity:" + entity);
        JSONObject json = new JSONObject(entity);
        String isbn2 = json.getString("isbn");
        System.out.println(isbn2);
    } catch (JSONException e){
        e.printStackTrace();
    }
}

The output is varied: Using the first approach, I've managed to somewhat access the request with the following output:

[[
{
    <Object here>
}=null
]]

The second approach aims to parse the request as a JSON Object but the reply i get is [application/json].

I have configured Postman to send json in headers and after an exhausting amount of research, I'm stuck. If anyone can provide me with some hints or research material, I would be indebted!

Thanks for your time!

java json postman

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Install OpenJDK 11 on CentOS 8

What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).

Set the JSON body from an external JSON file in Postman

In this short tutorial, I will show you how to get your entire JSON request body from an external file. This can be particularly useful if you want to use di...

Java Core (2020) | Java for beginners | Brush up your Java Skills | Get Hired

In this video we will learn about all the major concepts that come under Java Core . The course is very carefully designed and is made with keeping simplicit...

Introduction to JSON - Java

Learn the fundamentals of parsing and manipulating JSON data with the JSON-Java library.

Jackson 2 – Convert Java Object to / from JSON

Learn how to use Jackson 2 library to convert JSON to Java Object and convert Java Object to JSON. Learn how to convert Java Object to or from JSON using Jackson 2 with an example.