Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your issue results really weird for me... it seems that there must be some problem with Jersey's JSON serialization of single element arrays... if you Google "<em>Jersey JSON single element arrays</em>" you'll find the same issue, like <a href="http://tugdualgrall.blogspot.co.uk/2011/09/jax-rs-jersey-and-single-element-arrays.html" rel="nofollow noreferrer"><strong>here</strong></a> or <a href="https://stackoverflow.com/questions/13575280/jersey-json-array-with-1-element-is-serialized-as-object"><strong>here</strong></a>. I don't know too much about Jersey, so I can't help you with that...</p> <hr> <p>That said, I can suggest a workaround using manually parsing in Gson, to adapt your parsing to the 2 different responses (object or array). You could do something like this:</p> <pre><code>//manually parsing until get the "project" element... JsonParser parser = new JsonParser(); JsonObject rootObejct = parser.parse(yourJsonString).getAsJsonObject(); JsonElement projectElement = rootObejct.get("project"); Gson gson = new Gson(); List&lt;Project&gt; projectList = new ArrayList&lt;&gt;(); //Check if "project" element is an array or an object and parse accordingly... if (projectElement.isJsonObject()) { //The returned list has only 1 element Project project = gson.fromJson(projectElement, Project.class); projectList.add(project); } else if (projectElement.isJsonArray()) { //The returned list has &gt;1 elements Type projectListType = new TypeToken&lt;List&lt;Project&gt;&gt;() {}.getType(); projectList = gson.fromJson(projectElement, projectListType); } //Now you have a List&lt;Project&gt; projectList with one or many Project elements, //depending on the response... </code></pre> <p>Note that you don't need your class <code>ProjectContainer</code>.</p> <p>Something like this should work for you, although obviously the best thing would be fix the serialization issue!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload