当前位置: 首页>>代码示例>>Java>>正文


Java JSON.parseArray方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.JSON.parseArray方法的典型用法代码示例。如果您正苦于以下问题:Java JSON.parseArray方法的具体用法?Java JSON.parseArray怎么用?Java JSON.parseArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.JSON的用法示例。


在下文中一共展示了JSON.parseArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateUserInfo

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
@RequestMapping(value = "/updateUserInfo")
public String updateUserInfo(HttpServletRequest request, HttpServletResponse response, Model model, @RequestParam String data){
    List<UserInformationVO> listDTO = JSON.parseArray(data, UserInformationVO.class);
    for(UserInformationVO u: listDTO){
        int idDTO = u.getId();
        String passwordDTO = u.getPassword();
        String tel = u.getTel();
        String eMail = u.geteMail();
        if(!"".equals(tel)||!"".equals(eMail)){
            userInfoService.updateUserInfoById(idDTO, "", "", eMail, tel);
        }
        if(!"-1".equals(passwordDTO)){
            userService.updateUserById(idDTO, "", passwordDTO);
        }
    }
    return ajaxReturn(response,null, "修改成功", 0);
}
 
开发者ID:BetaSummer,项目名称:sztw,代码行数:18,代码来源:ManageController.java

示例2: process

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
@Override
    public void process(Page page) throws IOException {
        BeeExecutorPool beeThreadPool = new BeeExecutorPool(5);
        String api = page.getApi();
        String course_name = ((JSONObject) ((JSONObject) JSON.parse(api)).get("data")).get("course_name").toString();
        JSONArray video = JSON.parseArray( ((JSONObject) ((JSONObject) JSON.parse(api)).get("data")).get("video_list").toString());
        for(java.lang.Object v : video){
//            beeThreadPool.execute(() -> {
                String video_url = JSON.parseObject(v.toString()).get("video_url").toString();
                String video_name = JSON.parseObject(v.toString()).get("video_name").toString();
                System.out.println(video_name + " : " + video_url);
//                new FileDownloader(new Request(video_url), page.getTask()).downFileProcessor("/Users/zhuang/Desktop/", video_name);
                page.addWaitUrl(video_url);
//            });
        }
    }
 
开发者ID:java-webbee,项目名称:webBee,代码行数:17,代码来源:TestDownVideo.java

示例3: test_number

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
public void test_number() throws Exception {
    String text = "[0,1,-1,2E3,2E+3,2E-3,2e3,2e+3,2e-3]";
    JSONArray array = JSON.parseArray(text);

    Assert.assertEquals(0, array.get(0));
    Assert.assertEquals(1, array.get(1));
    Assert.assertEquals(-1, array.get(2));
    Assert.assertEquals(new BigDecimal("2E3"), array.get(3));
    Assert.assertEquals(new BigDecimal("2E3"), array.get(4));
    Assert.assertEquals(new BigDecimal("2E-3"), array.get(5));
    Assert.assertEquals(new BigDecimal("2E3"), array.get(6));
    Assert.assertEquals(new BigDecimal("2E3"), array.get(7));
    Assert.assertEquals(new BigDecimal("2E-3"), array.get(8));

    for (long i = Long.MIN_VALUE; i <= Long.MIN_VALUE + 1000 * 10; ++i) {
        Assert.assertEquals(i, JSON.parse(Long.toString(i)));
    }

    for (long i = Long.MAX_VALUE - 1000 * 10; i <= Long.MAX_VALUE && i > 0; ++i) {
        Assert.assertEquals(i, JSON.parse(Long.toString(i)));
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:LexerTest.java

示例4: convertJSONToArray

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
/**
 * <B>方法名称:</B>将JSON字符串数组转为List集合对象<BR>
 * <B>概要说明:</B>将JSON字符串数组转为List集合对象<BR>
 * @param data JSON字符串数组
 * @param clzss 转换对象
 * @return List<T>集合对象
 */
public static <T> List<T> convertJSONToArray(String data, Class<T> clzss) {
	try {
		List<T> t = JSON.parseArray(data, clzss);
		return t;
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:craware,项目名称:webapp-tyust,代码行数:17,代码来源:FastJsonConvert.java

示例5: test_0

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
public void test_0() throws Exception {

        List<Person> personList = new ArrayList<Person>();
        {
            Person p = new Person();
            p.setF1(true);
            p.setF2(true);
            p.setF3((byte) 3);
            p.setF4((byte) 4);
            p.setF5((short) 5);
            p.setF6((short) 6);
            p.setF7(7);
            p.setF8(8);
            p.setF9(9L);
            p.setF10(10L);
            p.setF11(new BigInteger("12345678901234567890123456789012345678901234567890"));
            p.setF12(new BigDecimal("1234567890123456789012345678901234567890.1234567890"));
            p.setF13("F13");
            p.setF14(new Date());
            p.setF15(15);
            p.setF16(16F);
            p.setF17(17);
            p.setF18(18D);
            personList.add(p);
        }
        {
            Person person = new Person();
            personList.add(person);
        }

        String jsonString = JSON.toJSONString(personList);


        JSON.parseArray(jsonString, Person.class);
        // CGLibExtJSONParser parser = new CGLibExtJSONParser(text);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:TypeUtilstTest.java

示例6: getGroup

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
/**
 * 查询所有分组
 *
 * @return
 */
public List<Group> getGroup() {
	String resultStr = HttpUtils.post(GROUP_GET_POST_URL + TokenProxy.accessToken());
	logger.info("return data " + resultStr);
	try {
		WeChatUtil.isSuccess(resultStr);
	} catch (WeChatException e) {
		logger.error(e.getMessage());
		e.printStackTrace();
		return null;
	}
	JSONObject jsonObject = JSONObject.parseObject(resultStr);
	List<Group> groups = JSON.parseArray(jsonObject.getString("groups"), Group.class);
	return groups;
}
 
开发者ID:funtl,项目名称:framework,代码行数:20,代码来源:UserManager.java

示例7: getList

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
/**
 * 通过fastJson获取class集合  String 集合 可直接传String.class
 *
 * @param json
 * @param cls
 * @return
 */
public static <T> List<T> getList(String json, Class<T> cls) {
    List<T> list;
    try {
        list = JSON.parseArray(json, cls);
        if (list != null) {
            return list;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return new ArrayList<>();
}
 
开发者ID:sundevin,项目名称:utilsLibrary,代码行数:20,代码来源:FastJsonUtils.java

示例8: delete

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
@ResponseBody
@PostMapping("/delete")
@ApiOperation(value = "机构管理-删除接口")
public BaseResult delete(String ids){
    BaseResult result=new BaseResult(BaseResultCode.SUCCESS,"删除成功");
    List<String> idList= JSON.parseArray(ids,String.class);
    int count= service.deleteByIds(idList);
    _log.info("删除了:"+count+"数据");
    return result;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:11,代码来源:OfficeController.java

示例9: checkjson

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
public boolean checkjson(String jsonstr) {
	try {
		JSON.parseArray(jsonstr);
		return true;
	} catch (Exception e) {
		return false;
	}
}
 
开发者ID:CharleyXu,项目名称:tulingchat,代码行数:9,代码来源:MsgDispatcher.java

示例10: updateFormManagerByApprover

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
@Override
public int updateFormManagerByApprover(int approver, String powerList, String lvList) {
    FormManager formManagerDTO = formManagerMapper.selectByApprover(approver);
    List<Integer> listDTO = new ArrayList<>();
    if(formManagerDTO!=null){
        listDTO = JSON.parseArray(formManagerDTO.getApproverForm(), Integer.class);
    }
    List<Integer> powerListDTO = JSON.parseArray(powerList, Integer.class);
    List<Integer> lvListDTO = JSON.parseArray(lvList, Integer.class);
    for(int i=0;i<lvListDTO.size();i++){
        int lv = lvListDTO.get(i);
        if(lv!=0){
            int formTypeDTO = 0;
            try{
                formTypeDTO = powerTypeService.getPowerTypeByPowerId(powerListDTO.get(i)).getFormType();
            }catch (Exception e){
                continue;
            }

            if(listDTO.size()<formTypeDTO){
                for(int j=listDTO.size();j<formTypeDTO-1;j++){
                    listDTO.add(j, -1);
                }
            }
            listDTO.set(formTypeDTO-1, lv);
        }
    }
    String strDTO = JSON.toJSONString(listDTO);
    if(formManagerDTO==null){
        FormManager formManagerDTO2 = new FormManager();
        formManagerDTO2.setApproverForm(strDTO);
        formManagerDTO2.setApprover(approver);
        return formManagerMapper.insert(formManagerDTO2);
    }
    formManagerDTO.setApproverForm(strDTO);
    return formManagerMapper.updateByApprover(formManagerDTO);
}
 
开发者ID:BetaSummer,项目名称:sztw,代码行数:38,代码来源:FormManagerServiceImpl.java

示例11: perf

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
public static void perf() {
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1000; ++i) {
        JSON.parseArray(json, IncomingDataPoint_ext_double.class);
    }
    long millis = System.currentTimeMillis() - start;
    System.out.println("IncomingDataPoint_double millis : " + millis);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:IncomingDataPointBenchmark_file_ext_double.java

示例12: perf

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
public static void perf() {
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1000 * 1000; ++i) {
        JSON.parseArray(json, IncomingDataPoint.class);
    }
    long millis = System.currentTimeMillis() - start;
    System.out.println("millis : " + millis);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:IncomingDataPointBenchmark.java

示例13: listProductTypes

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
public List<MagentoType> listProductTypes(int page, int pageSize) {
   String uri = baseUri() + "/rest/V1/products/types"
           + "?searchCriteria[currentPage]=" + page
           + "&searchCriteria[pageSize]=" + pageSize;
   String json = getSecured(uri);
   return JSON.parseArray(json, MagentoType.class);
}
 
开发者ID:chen0040,项目名称:java-magento-client,代码行数:8,代码来源:MagentoProductManager.java

示例14: test_for_issue

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
public void test_for_issue() {
    String jsonString = "[{\"author\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"a876c49c18\"},\"createdAt\":\"2017-07-02 20:06:13\",\"imgurl\":\"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=11075891,34401011&fm=117&gp=0.jpg\",\"name\":\"衣架\",\"objectId\":\"029d5493cd\",\"prices\":\"1\",\"updatedAt\":\"2017-07-02 20:06:13\"}]";
    JSONArray jsonArray = JSON.parseArray(jsonString);
    //jsonArray = new JSONArray(jsonArray);//这一句打开也一样是正确的
    double total = 0;
    for (int i = 0; i <jsonArray.size() ; i++) {
        JSONObject object=jsonArray.getJSONObject(i);
        assertEquals("衣架",object.getString("name"));
        total=total+ Double.valueOf(object.getString("prices"));
    }
    assertEquals(1.0d,total);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:Issue1303.java

示例15: scan

import com.alibaba.fastjson.JSON; //导入方法依赖的package包/类
/**
 * 定时扫描远程配置信息
 */
private boolean scan() {

    String listUrl = url + "/list";
    String jsonString = httpGet(listUrl);

    if (StringUtils.isBlank(jsonString)) {
        LogKit.error("can not get remote config info,plase check url : " + listUrl);
        return false;
    }

    JSONArray jsonArray = null;
    try {
        jsonArray = JSON.parseArray(jsonString);
    } catch (Throwable ex) {
        LogKit.error("can not parse json : \n" + jsonString + "\n\nfrom url : " + listUrl, ex);
        return false;
    }

    for (int i = 0; i < jsonArray.size(); i++) {
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        curScan.put(jsonObject.getString("id"), jsonObject.getString("version"));
    }

    return true;

}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:30,代码来源:ConfigRemoteReader.java


注:本文中的com.alibaba.fastjson.JSON.parseArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。