Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-361

JSON List Output format is wrong.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • 1.2.1.GA
    • None

    Description

      The output of a List method is too verbose. An example:

      @XmlRootElement
      public class TestA {

      private String str;

      public TestA() {
      }
      }

      @GET
      @Path("list")
      @Produces(MediaType.APPLICATION_JSON)
      public List<TestA> testListFormat() {
      List<TestA> l = new ArrayList<TestA>(3);
      l.add(new TestA("a"));
      l.add(new TestA("b"));
      l.add(new TestA("c"));
      List<JSONObject> jl = new ArrayList<JSONObject>(3);
      for (TestA a : l)

      { jl.add(new JSONObject(a)); }

      JSONArray jsa = new JSONArray(jl);
      log.info(jsa.toString());
      return l;
      }

      RESTeasy output format:
      [{"testA":{"str":"a"}},{"testA":{"str":"b"}},{"testA":{"str":"c"}}]

      JSONObject output format:
      [

      {"str":"a"}

      ,

      {"str":"b"}

      ,

      {"str":"c"}

      ]

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            flesner_jira Daniel Flesner (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: