title: How to map JSON request in REST webservice in MULE?
body: <p>I have a a requirement to expose a REST web service in Mue .. My Mule flow is as follow :-</p>
  
  <pre><code> &lt;flow name="MainService" doc:name="MainService"&gt;
   &lt;http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP"/&gt;
   &lt;jersey:resources doc:name="REST"&gt;
    &lt;component class="com.test.services.schema.maindata.v1.Impl.MainData"/&gt;
   &lt;/jersey:resources&gt;
   &lt;/flow&gt;
  </code></pre>
  
  <p>Now my question is if I post a JSON request to this REST service .. How can I map the request which is in a Sting format into a object mapped with input parameters of MainData class .. for example .. If I post the following JSON request from a REST client as a request body :- </p>
  
  <pre><code>{
      "insertDataRequest": [
          {
              "id": "288",
              "name": "Sidray",
              "age": "55",
              "designation": "SE"
          }
      ]
  }
  </code></pre>
  
  <p>The request gets into the flow as a String .. Now in Java class MainData, I can use GSON parser to parse the String .. but here I don't want to use GSON in Java class MainData to parse the String request and get id, name, age values  .. instead of that I want a Mule transformer or something like that to parse the String and map into an Object before the java class  so that in MainData class I can map with the input as following :-</p>
  
  <pre><code>public class MainData
  {
  @Override
      @POST
      @Produces("application/json")
      @Path("/insert/")
      public DataResponse insertDataOperation(int id,String name,int age,String designation)
  {
  // Here all the values like are mapped with input parameter
  }
  }
  </code></pre>
  
  <p>Is there any way in mule to convert the input request String  into an Object and map with input parameter ?? Is this the right approach to expose a REST webservice which intake a JSON request .. please suggest ??</p>