jersey
  1. jersey
  2. JERSEY-380

Add application property to set the default JSON convention

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.0.3
    • Fix Version/s: icebox
    • Component/s: core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      380

      Description

      When I attempt to serialize an array of one element as JSON, the serialization
      is failing to surround my element with backets[]. This is causing problems
      downstream since the expected result is a list.

      A very simple example of this:

      /**
      This example produces a result of

      {"data":"aaa"}

      and it should have produced

      {"data":["aaa"]}

      */
      import javax.ws.rs.GET;
      import javax.ws.rs.Path;
      import javax.ws.rs.Produces;
      import javax.ws.rs.core.MediaType;
      import javax.xml.bind.annotation.XmlElement;
      import javax.xml.bind.annotation.XmlRootElement;

      @Path("test.ui")
      public class Test {

      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public TestData getSessionState() {

      TestData rc = new TestData();
      rc.data = new String[]

      { "aaa" }

      ;
      return rc;
      }

      @XmlRootElement(name="TestDAta")
      public static class TestData

      { @XmlElement public String[] data; }

      }

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            drampulla
          • Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: