Jersey: read uploaded file as JSON
<p>I am able to upload a file in jersey in the following way:</p>

<pre><code>@POST
    @Consumes( MediaType.MULTIPART_FORM_DATA)
    public void indexFile(
            @FormDataParam("file") InputStream uploadedFile,
            @FormDataParam("file") FormDataContentDisposition fileInfo){
        System.out.println(fileInfo.getFileName());
        DAO.indexFileToSolr(uploadedFile);
    }
</code></pre>

<p>this gives me the file as a input stream.
This file contains an array of json objects in the following format:</p>

<pre><code>[
    {
        id: 1,
        title: "someTitle"
    }
]
</code></pre>

<p>I also have a POJO/ Java class representing this object like this:</p>

<pre><code>@XmlRootElement
public class MyObj{
    private int id;
    private String title;

   //getters and setters
}
</code></pre>

<p>I am using <code>jersey-media-moxy</code> to automatically convert between POJO and JSON/XML at the time of incoming request or outgoing response. 
(I don't need to write any code for this, i just need to specify that the request will be in JSON format, or the response should be JSON, and the serialization/deserialization is handled by <code>jersey-media-moxy</code>.)</p>

<p>The issue is , i am not able to specify this behavior in the file upload method, i see no way of telling jersey or <code>jersey-media-moxy</code> to serialize the file to java objects.</p>

<p>I could not find any methods in <code>jersey-media-moxy</code> to actually read a InputStream and serialize it to a POJO.</p>

<p>NOTE: i can probably use <code>jackson</code> to read the json file and create a list of Java objects, but i am not very inclined to do so, firstly because that requires another library (it would be great if i can do this with jersey-media-mosy) and secondly, i am not sure whether there could be a easy way to just tell jersey that this file contains Json objects so, de-serialize it.</p>