使用jsonbody请求进行字符串/ int转换的JSON

时间:2015-08-13 13:32:04

标签: java web-services jax-rs

您好我试图使用post请求在请求正文中引入字符串和整数,这样做的最佳方法是什么? 在休息客户端中输入类似的内容,例如:

{
    "name":"ExName",
    "reading":"100"
}

@POST
    @Path("/SetFeeds")
    @Consumes(MediaType.APPLICATION_JSON)   
    @Produces(MediaType.APPLICATION_JSON) 
    @JsonCreator
    //public String setFeed(@PathParam("name")String name2, @QueryParam("name") String name,@Context UriInfo uriInfo,String jsonBody){
        public String setFeed(String jsonBody,@Context UriInfo uriInfo){        
            MultivaluedMap<String,String> queryParams = uriInfo.getQueryParameters();
            String query = uriInfo.getRequestUri().getQuery();
            String response = queryParams.getFirst("name");
            System.out.println(response);
            //System.out.println(name2);
            //JSONObject jsonObject = new JSONObject();
            //JSONObject nodeStats = name.get(getJSONObject("name"));
            // Getting the value of a attribute in a JSONObject
            //String sSDR = actualObj.getString("sdr");
            //FeedObjects x=new FeedObjects();
            //System.out.println(x.getName());


            return response;

    } 

0 个答案:

没有答案