Java Code Examples for org.nutz.json.Json#fromJsonAsList()

The following examples show how to use org.nutz.json.Json#fromJsonAsList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FoodController.java    From flash-waimai with MIT License 5 votes vote down vote up
@RequestMapping(value = "/v2/updatefood",method = RequestMethod.POST)
public Object update(@ModelAttribute @Valid FoodVo food){
    List<SpecVo> specVoList = Json.fromJsonAsList(SpecVo.class,food.getSpecsJson());
    List<SpecFood> specList = Lists.newArrayList();
    for(SpecVo specVo:specVoList){
        SpecFood specFood = new SpecFood();
        specFood.setName(specVo.getSpecs());
        specFood.setPrice(Double.valueOf(specVo.getPrice()));
        specFood.setPacking_fee(Double.valueOf(specVo.getPacking_fee()));
        specFood.setSpecs_name(specVo.getSpecs());
        specList.add(specFood);
    }
    Food old = mongoRepository.findOne(Food.class,"item_id",food.getId());
    old.setName(food.getName());
    old.setPinyin_name(StringUtils.getPingYin(food.getName()));
    old.setDescription(food.getDescript());
    old.setCategory_id(food.getIdMenu());
    old.setImage_path(food.getImagePath());
    old.setSpecfoods(specList);
    mongoRepository.update(old);
    Menu menu = mongoRepository.findOne(Menu.class,old.getCategory_id());
    for(Food item:menu.getFoods()){
        if(item.getItem_id().intValue() == old.getItem_id().intValue()){
            menu.getFoods().remove(item);
            menu.getFoods().add(old);
            break;
        }
    }
    mongoRepository.update(menu);
    return Rets.success();
}
 
Example 2
Source File: WechatAPIImpl.java    From mpsdk4j with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getServerIps() {
    String url = mergeCgiBinUrl(callBackIPSURL + getAccessToken());
    APIResult ar = wechatServerResponse(url,
            HTTP_GET,
            NONE_BODY,
            "获取公众号[%s]服务器IP列表失败.");
    return Json.fromJsonAsList(String.class, Json.toJson(ar.get("ip_list")));
}
 
Example 3
Source File: WechatAPIImpl.java    From mpsdk4j with Apache License 2.0 5 votes vote down vote up
@Override
public List<Menu> getMenu() {
    String url = mergeCgiBinUrl(getMenuURL + getAccessToken());
    APIResult ar = wechatServerResponse(url,
            HTTP_GET,
            NONE_BODY,
            "获取公众号[%s]的自定义菜单失败.");
    // 菜单为空
    if (ar.getErrCode() != null && ar.getErrCode().intValue() == 46003) {
        return null;
    }

    Map<String, Object> button = Json.fromJson(Map.class, Json.toJson(ar.get("menu")));
    return Json.fromJsonAsList(Menu.class, Json.toJson(button.get("button")));
}
 
Example 4
Source File: WechatAPIImpl.java    From mpsdk4j with Apache License 2.0 5 votes vote down vote up
@Override
public List<Groups> getGroups() {
    String url = mergeCgiBinUrl(getGroupsURL + getAccessToken());
    APIResult ar = wechatServerResponse(url,
            HTTP_GET,
            NONE_BODY,
            "获取公众号[%s]的所有分组信息失败.");
    return Json.fromJsonAsList(Groups.class, Json.toJson(ar.get("groups")));
}
 
Example 5
Source File: WechatAPIImpl.java    From mpsdk4j with Apache License 2.0 5 votes vote down vote up
@Override
public List<Follower> getFollowers(Collection<Follower2> users) {
    String url = mergeCgiBinUrl(batchUserInfoURL + getAccessToken());
    String data = Json.toJson(Lang.map("user_list", users), JsonFormat.compact());
    APIResult ar = wechatServerResponse(url,
            HTTP_POST,
            data,
            "批量获取公众号[%s]的%d个用户信息失败.",
            users.size());
    return Json.fromJsonAsList(Follower.class, Json.toJson(ar.get("user_info_list")));
}
 
Example 6
Source File: SendPhotosEvent.java    From mpsdk4j with Apache License 2.0 4 votes vote down vote up
public SendPhotosEvent(Map<String, String> values) {
    super(values);
    List<PicItem> items = Json.fromJsonAsList(PicItem.class, values.get("picList"));
    this.sendPicsInfo = new SendPicsInfo(Integer.parseInt(values.get("count")), items);
}