Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 无根元素名称resteasy响应_Json_Hibernate_Resteasy - Fatal编程技术网

Json 无根元素名称resteasy响应

Json 无根元素名称resteasy响应,json,hibernate,resteasy,Json,Hibernate,Resteasy,返回具有指定对象根名称的对象列表时遇到一些问题。我试过几种不同的方法。我确信我总是在做一些非常愚蠢的事情,我感谢任何帮助 这是我的目标 @XmlRootElement @JsonRootName(value = "Bixasset") @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) @Produces("application/json") @Indexed public class Bixasset impl

返回具有指定对象根名称的对象列表时遇到一些问题。我试过几种不同的方法。我确信我总是在做一些非常愚蠢的事情,我感谢任何帮助

这是我的目标

@XmlRootElement
@JsonRootName(value = "Bixasset")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Produces("application/json")
@Indexed    
public class Bixasset implements java.io.Serializable {
    @Id
    private UUID id;

    private Client client;

    private String name;

    private String asseturl;
    private Character active;
    private Integer width;
    private Integer height;
    private String thumbnailurl;
    private Date createddate;
    private String filetype;
    private String category;


    public Bixasset() {
    }

    public Bixasset(UUID id) {
        this.id = id;
    }

    public Bixasset(UUID id, Client client, String name, String asseturl,Character active, Integer width, Integer height, String thumbnailurl
        ,Date createddate, String filetype, String category) {
        this.id = id;
        this.client = client;
        this.name = name;
        this.asseturl = asseturl;
        this.active = active;
        this.width = width;
        this.height = height;
        this.thumbnailurl = thumbnailurl;
        this.createddate = createddate;
        this.filetype = filetype;
        this.category = category;


    }



    public UUID getId() {
        return this.id;
    }

    public void setId(UUID id) {
        this.id = id;
    }
    @ManyToOne(fetch=FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
    @JoinColumn(name="clientid")
    public Client getClient() {
        return this.client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAsseturl() {
        return asseturl;
    }

    public void setAsseturl(String asseturl) {
        this.asseturl = asseturl;
    }

    public Character getActive() {
        return active;
    }

    public void setActive(Character active) {
        this.active = active;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getHeight() {
        return height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }

    public String getThumbnailurl() {
        return thumbnailurl;
    }

    public void setThumbnailurl(String thumbnailurl) {
        this.thumbnailurl = thumbnailurl;
    }

    public Date getCreateddate() {
        return createddate;
    }

    public void setCreateddate(Date createddate) {
        this.createddate = createddate;
    }

    public String getFiletype() {
        return filetype;
    }

    public void setFiletype(String filetype) {
        this.filetype = filetype;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    }
这是我的方法

@Path("/bixasset/")
@Produces(MediaType.APPLICATION_JSON)
public Response queryBixAsset(@QueryParam("id") String id, @QueryParam("filetype") String filetype, @QueryParam("category") String category,   @QueryParam("token") String token) {
    try{

        List<Bixasset> results = new ArrayList<Bixasset>(); 


        UUID ClientId = dAL.validateToken(token);

        if(token != null && ClientId != null){


                String query ="FROM Bixasset WHERE client.id = '" + ClientId + "' "; 


                if(id != null && !id.equals(""))
                    query += " AND id = '" + id + "'";

                if(filetype != null && !filetype.equals(""))
                    query += " AND filetype.id = '" + filetype + "'";

                if(category != null && !category.equals(""))
                    query += " AND category = '" + category + "'";




                query+= "  LIMIT 1000";
                results = dAL.query(query);
                System.out.println("query size" + results.size());


        }else{
            return Response.status(401).build();
        }


        return Response.ok(results).build();
    }catch(Exception e){
        return Response.status(400).build();
    }
}
希望我的结果看起来像

   {"Bixasset" [
  {
    "id": "99f516a2-f7ef-4bc9-a627-73981a2fc3ae",
    "client": {
      "id": "388e16d6-d35e-4f8c-bba5-b1147b824473",
      "reseller": null,
      "name": "Phizzle",
      "createddate": 1357554435574,
      "address1": "123",
      "address2": "",
      "city": "San Francisco",
      "state": "CA",
      "postalcode": "80130",
      "country": "USA",
      "description": "Phizzle Master Client"
    },
    "name": "gears_animated.gif",
    "asseturl": "https://s3.amazonaws.com/adsdadd/99f516a2-f7ef-4bc9-a627-73981a2fc3ae.gif",
    "active": "0",
    "width": 141,
    "height": 141,
    "thumbnailurl": "https://s3.amazonaws.com/adadsd/99f516a2-f7ef-4bc9-a627-73981a2fc3ae__thumbnail.jpg",
    "createddate": 1380927929287,
    "filetype": "image/gif",
    "category": "Images"
  }
] }

您是否尝试设置@XmlRootElement的注释变量而不是使用@JsonRootName? 我的意思是:


不要掷骰子!谢谢你的努力。
   {"Bixasset" [
  {
    "id": "99f516a2-f7ef-4bc9-a627-73981a2fc3ae",
    "client": {
      "id": "388e16d6-d35e-4f8c-bba5-b1147b824473",
      "reseller": null,
      "name": "Phizzle",
      "createddate": 1357554435574,
      "address1": "123",
      "address2": "",
      "city": "San Francisco",
      "state": "CA",
      "postalcode": "80130",
      "country": "USA",
      "description": "Phizzle Master Client"
    },
    "name": "gears_animated.gif",
    "asseturl": "https://s3.amazonaws.com/adsdadd/99f516a2-f7ef-4bc9-a627-73981a2fc3ae.gif",
    "active": "0",
    "width": 141,
    "height": 141,
    "thumbnailurl": "https://s3.amazonaws.com/adadsd/99f516a2-f7ef-4bc9-a627-73981a2fc3ae__thumbnail.jpg",
    "createddate": 1380927929287,
    "filetype": "image/gif",
    "category": "Images"
  }
] }
@XmlRootElement(name = "Bixasset")