Java Code Examples for com.alibaba.fastjson.JSON#parseArray()

The following examples show how to use com.alibaba.fastjson.JSON#parseArray() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: aliyun-tsdb-java-sdk   File: TSDBClient.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<LastDataValue> queryLast(Collection<Timeline> timelines) throws HttpUnknowStatusException {
    Object timelinesJSON = JSON.toJSON(timelines);
    JSONObject obj = new JSONObject();
    obj.put("queries", timelinesJSON);
    String jsonString = obj.toJSONString();
    HttpResponse httpResponse = httpclient.post(HttpAPI.QUERY_LAST, jsonString);
    ResultResponse resultResponse = ResultResponse.simplify(httpResponse, this.httpCompress);
    HttpStatus httpStatus = resultResponse.getHttpStatus();
    switch (httpStatus) {
        case ServerSuccessNoContent:
            return null;
        case ServerSuccess:
            String content = resultResponse.getContent();
            List<LastDataValue> queryResultList = JSON.parseArray(content, LastDataValue.class);
            return queryResultList;
        case ServerNotSupport:
            throw new HttpServerNotSupportException(resultResponse);
        case ServerError:
            throw new HttpServerErrorException(resultResponse);
        case ServerUnauthorized:
            throw new HttpServerUnauthorizedException(resultResponse);
        default:
            throw new HttpUnknowStatusException(resultResponse);
    }
}
 
Example 2
/**
 * 获取客服聊天记录
 * @param starttime 查询开始时间,UNIX时间戳
 * @param endtime 查询结束时间,UNIX时间戳,每次查询不能跨日查询
 * @param pageindex 查询第几页,从1开始
 * @param pagesize 每页大小,每页最多拉取50条
 * @return
 */
public List<Record> getRecord(long starttime,long endtime, int pageindex,int pagesize) {
	JSONObject data = new JSONObject();
	data.put("endtime", endtime);
	data.put("pageindex", pageindex);
	data.put("pagesize", pagesize);
	data.put("starttime", starttime);
	String resultStr = HttpUtils.post(CUSTOMSERVICE_MSGRECORD_GETRECORD_POST_URL+this.accessToken, data.toJSONString());
	try {
		WeChatUtil.isSuccess(resultStr);
	} catch (WeChatException e) {
		logger.error(e.getMessage());
		e.printStackTrace();
		return null;
	}
	String recordlist = JSON.parseObject(resultStr).getString("recordlist");
	List<Record> records = JSON.parseArray(recordlist, Record.class);
	return records;
}
 
Example 3
Source Project: s2g-zuul   File: HttpZuulFilterDao.java    License: MIT License 6 votes vote down vote up
@Override
public List<FilterInfo> getAllCanaryFilters() throws Exception {
	List<FilterInfo> list = Lists.newArrayList();
	
	HttpGet method = new HttpGet(filterRepository.get()+"/canary/"+applicationName);
	
	CloseableHttpResponse response = httpclient.execute(method);
	
	String body = EntityUtils.toString(response.getEntity());
	JSONArray jsonArray = JSON.parseArray(body);
	
	for(int i=0;i<jsonArray.size();i++){
		JSONObject json = jsonArray.getJSONObject(i);
		
		FilterInfo filter = JSON.toJavaObject(json, FilterInfo.class);
		
		filter.setFilterCode(new String(Base64.decodeBase64(filter.getFilterCode().getBytes("utf-8")),"utf-8"));
		list.add(filter);
	}
	return list;
}
 
Example 4
/**
 * 更新网站编程语言选项.
 * @param languages - 包含编程语言设置的数组
 * @param request - HttpServletRequest对象
 * @return 编程语言选项的更新结果
 */
@RequestMapping(value="/updateLanguageSettings.action", method=RequestMethod.POST)
public @ResponseBody Map<String, Object> updateLanguageSettingsAction(
		@RequestParam(value="languages") String languages,
		HttpServletRequest request) {
	List<Language> languagesList = JSON.parseArray(languages, Language.class);
	Map<String, Object> result = languageService.updateLanguageSettings(languagesList);
	return result;
}
 
Example 5
@Override
public List<PostSimpleDto> getPostRankingByPostView(Integer limit) {
    String value = redisUtil.get(RedisKeys.ALL_POST_RANKING_BY_VIEWS);
    // 先从缓存取,缓存没有从数据库取
    if (StringUtils.isNotEmpty(value)) {
        return JSON.parseArray(value, PostSimpleDto.class);
    }
    List<PostSimpleDto> postList = postMapper.getPostRankingByPostView(limit);
    redisUtil.set(RedisKeys.ALL_POST_RANKING_BY_VIEWS, JSON.toJSONString(postList), RedisKeyExpire.ALL_POST_RANKING_BY_VIEWS);
    return postList;
}
 
Example 6
@SysLog("批量删除字典")
@DeleteMapping(value = "/web/delBatch")
@ApiOperation(value = "批量删除数据字典管理-后端管理数据字典管理", notes = "批量删除数据字典管理-后端管理数据字典管理")
public ApiResponse deleteBatchDict(@RequestBody String ids){
    if (StringUtils.isBlank(ids)) {
        return fail("参数不能为空");
    }
    List<String> idList = JSON.parseArray(((JSONArray) JSON.parseObject(ids).get("ids")).toJSONString(), String.class);
    if (dictService.deleteBatchDict(idList)){
        return success("批量删除成功");
    }else {
        return fail("批量删除失败");
    }
}
 
Example 7
@Override
    protected Klines transformKlines(List<String> results, ExchangeInfo info) {
        String result = results.get(0);
        if (useful(result)) {
            JSONArray array = JSON.parseArray(result);
            List<Kline> klines = new ArrayList<>(array.size());
            for (int i = array.size() - 1; 0 <= i; i--) {
                JSONArray t = array.getJSONArray(i);
                /*
                 * 1499040000000,      // Open time
                 * "0.01634790",       // Open
                 * "0.80000000",       // High
                 * "0.01575800",       // Low
                 * "0.01577100",       // Close
                 * "148976.11427815",  // Volume
                 * 1499644799999,      // Close time
                 * "2434.19055334",    // Quote asset volume
                 * 308,                // Number of trades
                 * "1756.87402397",    // Taker buy base asset volume
                 * "28.46694368",      // Taker buy quote asset volume
                 * "17928899.62484339" // Ignore.
                 */
                Long time = t.getLong(0) / 1000;
                Kline kline = CommonUtil.parseKlineByIndex(array.getString(i), t, time, 1);
                klines.add(kline);
//                    if (size <= records.size()) break;
            }
            return new Klines(klines);
        }
        return null;
    }
 
Example 8
@DeleteMapping(value = "/web/delBatch")
@ApiOperation(value = "批量删除日志管理-后端管理日志管理", notes = "批量删除日志管理-后端管理日志管理")
public ApiResponse deleteBatchApiLogger(@RequestBody String ids) {
    if (StringUtils.isBlank(ids)) {
        return fail("参数不能为空");
    }
    List<String> idList = JSON.parseArray(((JSONArray) JSON.parseObject(ids).get("ids")).toJSONString(), String.class);
    if (apiLoggerService.deleteBatchApiLogger(idList)) {
        return success("批量删除成功");
    } else {
        return fail("批量删除失败");
    }
}
 
Example 9
/**
 * 查看日志 - 列表
 * @return
 */
@RequestMapping(value = "/rzList")
@ResponseBody
@CrossOrigin
public JSONArray rzList(String rzTime) {

    List<Rz> list = rwService.rzList(rzTime);
    String jsonStr = JsonUtil.serializeDate(list);
    return JSON.parseArray(jsonStr);
}
 
Example 10
@Override
public List<TopicPartitionGroup> findByTopic(String topic, String namespace) {
    PartitionGroupQuery query = new PartitionGroupQuery();
    query.setTopic(topic);
    query.setNamespace(namespace);

    String result = post(GETBYTOPIC_PARTITIONGROUP, query);
    List<PartitionGroup> partitionGroups = JSON.parseArray(result, PartitionGroup.class);
    return partitionGroups.stream().map(partitionGroup -> nsrPartitionGroupConverter.revert(partitionGroup)).collect(Collectors.toList());
}
 
Example 11
@RequestMapping(value = "/getHysList")
@ResponseBody
@CrossOrigin
public JSONArray getHysList() {
    List<Hys> list = userService.hysList();
    String jsonStr = JsonUtil.serializeDate(list);
    return JSON.parseArray(jsonStr);
}
 
Example 12
Source Project: ucar-weex-core   File: UWXResManager.java    License: Apache License 2.0 5 votes vote down vote up
private void iniWXInfo() {
    String packageJson = preferences.getString("wx_res_info", "");
    try {
        packageInfos = JSON.parseArray(packageJson, WXPackageInfo.class);
        this.lastPackageInfo = !ArrayUtils.isEmpty(packageInfos) ? packageInfos.get(0) : null;
    } catch (JSONException e) {
        packageInfos = null;
        UWLog.e(TAG, e.getMessage());
    }
}
 
Example 13
Source Project: TvPlayer   File: PlayListCache.java    License: Apache License 2.0 5 votes vote down vote up
public static void initPlayInfo(String userName,String password) throws Exception{
    String playList = HttpUtils.getOfflinePlayList();
    JSONArray jsonArray = JSON.parseArray(playList);
    PlayListCache.groupInfoArray = new String[jsonArray.size() + 1];
    PlayListCache.groupInfoArray[0] = "我的频道";
    if (jsonArray != null && jsonArray.size() > 0) {
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jo = jsonArray.getJSONObject(i);
            //分组
            String group = (String) jo.get("group");
            PlayListCache.groupInfoArray[i + 1] = group;
            JSONArray list = jo.getJSONArray("list");
            if (list != null && list.size() > 0) {
                ArrayList<HashMap<String, String>> hashMaps = new ArrayList<HashMap<String, String>>();
                int no = 0;
                for (int j = 0; j < list.size(); j++) {
                    JSONObject o = list.getJSONObject(j);
                    HashMap<String, String> m = new HashMap<String, String>();
                    for (String k : o.keySet()) {
                        String v = (String) o.get(k);
                        m.put("title", k);
                        m.put("no", String.valueOf(++no));
                        channelInfoList.add(v);
                        PlayListCache.playListMap.put(k, v);
                        hashMaps.add(m);
                    }
                }
                PlayListCache.groupInfo.put(group, hashMaps);
            }
        }
    }
}
 
Example 14
/**
 * 将给定的 JSON 字符串转换成JsonArray的类型对象。
 * 
 * @param <T>
 *            要转换的目标类型。
 * @param json
 *            给定的 JSON 字符串。
 * @return 给定的 JSON 字符串表示的指定的类型对象。
 */
public static JSONArray fromJsonArray(String json) {
	if (StringUtils.isBlank(json)) {
		return null;
	}
	JSONArray array = new JSONArray();
	try {
		array = JSON.parseArray(json);
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return array;
}
 
Example 15
Source Project: linden   File: LindenFieldCacheImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Accountable createValue(final AtomicReader reader, CacheKey key, boolean setDocsWithField)
    throws IOException {
  int maxDoc = reader.maxDoc();

  final long[][] matrix = new long[maxDoc][];
  BinaryDocValues valuesIn = reader.getBinaryDocValues(key.field);
  if (valuesIn == null) {
    for (int i = 0; i < maxDoc; ++i) {
      matrix[i] = new long[0];
    }
    return new LongList(matrix);
  }
  for (int i = 0; i < maxDoc; ++i) {
    String str = valuesIn.get(i).utf8ToString();
    if (StringUtils.isEmpty(str)) {
      matrix[i] = new long[0];
      continue;
    }
    JSONArray array = JSON.parseArray(str);
    matrix[i] = new long[array.size()];
    for (int j = 0; j < array.size(); ++j) {
      matrix[i][j] = array.getInteger(j);
    }
  }
  return new LongList(matrix);
}
 
Example 16
private Object resolveParam(Invoker invoker, Class<?> paramClass, Annotation pAnno) {
    Object atData = null;
    //
    if (pAnno instanceof AttributeParameter) {
        atData = this.getAttributeParam(invoker, (AttributeParameter) pAnno);
    } else if (pAnno instanceof CookieParameter) {
        atData = this.getCookieParam((CookieParameter) pAnno);
    } else if (pAnno instanceof HeaderParameter) {
        atData = this.getHeaderParam((HeaderParameter) pAnno);
    } else if (pAnno instanceof QueryParameter) {
        atData = this.getQueryParam((QueryParameter) pAnno);
    } else if (pAnno instanceof PathParameter) {
        atData = this.getPathParam((PathParameter) pAnno);
    } else if (pAnno instanceof RequestParameter) {
        atData = this.getRequestParam((RequestParameter) pAnno);
    } else if (pAnno instanceof RequestBody) {
        if (paramClass == String.class) {
            atData = invoker.getJsonBodyString();
        } else if (paramClass == Map.class) {
            atData = JSON.parseObject(invoker.getJsonBodyString());
        } else if (paramClass == List.class) {
            atData = JSON.parseArray(invoker.getJsonBodyString(), ArrayList.class);
        } else if (paramClass == Set.class) {
            atData = JSON.parseArray(invoker.getJsonBodyString(), HashSet.class);
        } else {
            atData = JSON.parseObject(invoker.getJsonBodyString(), paramClass);
        }
    } else if (pAnno instanceof ParameterGroup) {
        try {
            atData = invoker.getAppContext().justInject(paramClass.newInstance());
            atData = this.getParamsParam(invoker, paramClass, atData);
        } catch (Throwable e) {
            logger.error(paramClass.getName() + "newInstance error.", e.getMessage());
            atData = null;
        }
    }
    return atData;
}
 
Example 17
Source Project: springboot-learn   File: RedisClient.java    License: MIT License 5 votes vote down vote up
public <T> List<T> getList(final String key, Class<T> clazz) {
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        String value = jedis.get(key);
        return JSON.parseArray(value, clazz);
    } catch (Exception e) {
        logger.error("[RedisClient] getList e,", e);
        return new ArrayList<>();
    } finally {
        close(jedis);
    }
}
 
Example 18
public void start(){
    //查询鉴黄key
    Imgreview imgreview = schedulerTask.imgreviewService.selectByPrimaryKey(1);
    if(imgreview.getUsing()==1){
        //初始化鉴黄
        SchedulerTask.Initializes(imgreview);
        //计算出昨天的日期
        Date d = new Date();
        SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
        String oldtime = df.format(new Date(d.getTime() - 1 * 24 * 60 * 60 * 1000));
        //服务器获取出这个时间段的值然后遍历
        List<Images> imglist=  schedulerTask.imgService.gettimeimg(oldtime);
        for (Images images : imglist) {
            String imgurl = images.getImgurl();
            System.err.println("正在鉴定的图片:" + imgurl);
            JSONObject res = client.antiPorn(imgurl);
            res = client.imageCensorUserDefined(imgurl, EImgType.URL, null);
            System.err.println("返回的鉴黄json:"+res.toString());
            com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray("[" + res.toString() + "]");
            for (Object o : jsonArray) {
                com.alibaba.fastjson.JSONObject jsonObject = (com.alibaba.fastjson.JSONObject) o;
                com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data");
                Integer conclusionType = jsonObject.getInteger("conclusionType");
                if (conclusionType == 2) {
                    for (Object datum : data) {
                        com.alibaba.fastjson.JSONObject imgdata = (com.alibaba.fastjson.JSONObject) datum;
                        if (imgdata.getInteger("type") == 1) {
                            //标记图片
                            Integer ret = schedulerTask.imgService.deleimgname(images.getImgname()); //删除数据库图片信息
                            //Imgreview imgreview1  =imgreviewService.selectByPrimaryKey(1);
                            Imgreview imgreview1 = new Imgreview();
                            imgreview1.setId(1);
                            Integer count = imgreview.getCount();
                            System.out.println("违法图片总数:" + count);
                            imgreview1.setCount(count + 1);
                            schedulerTask.imgreviewService.updateByPrimaryKeySelective(imgreview1);
                            Keys key =null;
                            if(images.getSource()==1){
                                key = keysService.selectKeys(images.getSource());
                                schedulerTask.imgService.delect(key, images.getImgname());
                            }else if (images.getSource()==2){
                                key = keysService.selectKeys(images.getSource());
                                schedulerTask.imgService.delectOSS(key, images.getImgname());
                            }else if(images.getSource()==3){
                                key = keysService.selectKeys(images.getSource());
                                schedulerTask.imgService.delectUSS(key, images.getImgname());
                            }else if(images.getSource()==4){
                                key = keysService.selectKeys(images.getSource());
                                schedulerTask.imgService.delectKODO(key, images.getImgname());
                            }else if(images.getSource()==5){
                                LocUpdateImg.deleteLOCImg(images.getImgname());
                            }else if(images.getSource()==6){
                                key = keysService.selectKeys(images.getSource());
                                schedulerTask.imgService.delectCOS(key, images.getImgname());
                            }else if(images.getSource()==7){
                                key = keysService.selectKeys(images.getSource());
                                schedulerTask.imgService.delectFTP(key, images.getImgname());
                            }else{
                                System.err.println("未获取到对象存储参数,上传失败。");
                            }
                            if (ret == 1) {
                                System.err.println("存在色情图片,删除成功。");
                            } else {
                                System.err.println("存在色情图片,删除失败");
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 19
Source Project: neural   File: SerializeUtils.java    License: MIT License 4 votes vote down vote up
public static List parseList(String json) {
    return JSON.parseArray(json, List.class);
}
 
Example 20
Source Project: jfinal-ext3   File: FastJsonKit.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * json to array
 * @param <T>
 * @param json
 * @return
 */
public static JSONArray jsonToJSONArray(String json) {
	return JSON.parseArray(json);
}