How to get plain JSON data in jersey REST implementation?

jersey client post json example
how to implement rest api in java
how to get xml response from rest webservice in java
consuming rest services in java json
java rest client json example
java rest api return json
how to pass object to rest webservice in java

If we have a POJO class, then we can map it with some incoming JSON. I am struggling to find out a way by which I can just have all plain json value inside.

For ex.

    "macro_tasks": [
            "id": "cc5cee68-c1e5-4396-987b-c68559399186",
            "label": "consi-1",
            "name": "Consi 1",
            "project_id": "82d1e463-1bb1-42d3-9adc-9e0d5848d139",
            "creator_id": null,
            "created_at": null,
            "updated_at": null,
            "meta_data": {
                "key1": "value1",
                "key2": 321

Here meta_data is of JSON type which can keep changing its values inside. So I cannot map it with some POJO class.

public class MacroTask {

    private UUID id;
    private String label;
    private String name;

    private UUID projectId;

    private UUID creatorId;

    private String createdAt;

    private String updatedAt;

    private <some data type> meta_data;

//getter and setter

Is there any way to get plain JSON data and use it in code and dump into DB [we are using PostgreSQL, which supports jsonb type.]

I solved it by using Generic JSON type, Jackson's JsonNode. It has some drawbacks as I heard, but I am giving it a try. So far, it's working as per expectations. I will update if I face any challenge or I find any better solution.

Configuring JSON for RESTful Web Services in Jersey 1.0, JAX-RS, the Java API for RESTful Web Services (JSR-311). Jersey makes it In this tip you will learn how to configure data in JSON (JavaScript The Java method will process HTTP GET requests @GET type "text/plain" In this tutorial, we have used create a RESTFul application which sends JSON data to the client. We used Tomcat web server and Jersey framework. You might also be interested in the following related tutorials: Java tutorial , JAX-RS @PathParam tutorial , JAX-RS @QueryParam tutorial , Jersey Hello World tutorial , Spring Boot Jersey tutorial

You can use map; like

private Map<String, Object> meta_data;

JSON example with Jersey + Jackson –, It will make Jersey support JSON/object mapping. can create a RESTful client (​refer to this Jersey client APIs example), and “post” the json  RESTful Web Services and Bootstrapping With Jersey Implementation Read this tutorial in order to learn how to configure the Jersey servlet and bootstrap a project. Also learn about RESTful web

I got following error

Can not deserialize instance of java.lang.String out of START_OBJECT

I was using this code for json string to HasMap conversion.

Map map = mapper.readValue(jsonString, new TypeReference<HashMap<String,String>>(){});

I replaced it with.

Map map = mapper.readValue(jsonString, new TypeReference<HashMap<String,Object>>(){});

Jersey, How do I get JSON data from a RESTful web service? Building REST web service using Jersey by Hussein Terek · October 23, 2017 Since Java 5, JAX-RS specification has been announced in order to support building REST web services according to the REST architectural pattern.

Why not use meta_data as a field of type string instead of array? Then you could add the plain JSON as a string and use this value in your backend.

//add json as string value to this field    
private String meta_data;

RESTful Web Services - Quick Guide, Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) Reference Implementation. Jersey is an open source framework for developing REST web services that provide support for JAX-RS APIs and serves as a JAX-RS reference implementation. In this tutorial, we'll look at how we can set up a Jersey response body with different media types.

JSON Example With Jersey and Jackson, Then check out our detailed example on JSON With Jersey and Jackson! Jackson is used to marshal a Java Object to JSON, and ummarshal a JSON So make sure you read carefully Jersey Hello World Example and pay  How to create and configure JAX-RS JSON Rest Service with Jersey. We will explain how to create a jersey rest service version 1 and version 2. Here is how..

Set a Response Body in JAX-RS, Jersey is an open source framework for developing REST web services that All the examples here are HTTP GET requests, and we'll be using the curl a simple example of how plain text can be returned as a Jersey response: The Person POJO can now be used to return JSON as the Response body:. Last modified on May 31st, 2015 by Joe. This tutorial is part of the ongoing web services tutorial series. We will see about creating a RESTful web service using Jersey to produce JSON response. A RESTful web service can be configured to produce different types of response like XML, JSON, html, plain text and most of the MIME types.

Java RESTful Web Services With JSON and Jersey, We will see about creating a RESTful web service using Jersey to produce. different types of response like XML, JSON, html, plain text and most of the MIME types. Go through my Maven in 10 minutes tutorial if you are new to it. pumping-in some default data Product product = new Product("1001",  This Tech Tip will show you how to write RESTful web services in Java that conform to the JAX-RS: Java API for RESTful Web Services (JSR-311) specification and its reference implementation - Jersey. You'll learn some of the principles of Representational State Transfer (REST) and get introduced to JAX-RS and Jersey.