Java Code Examples for com.alibaba.fastjson.JSONObject#getBooleanValue()

The following examples show how to use com.alibaba.fastjson.JSONObject#getBooleanValue() . 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 check out the related API usage on the sidebar.
Example 1
@Override
public VideoDetails getVideoDetails(JSONObject config) {
    JSONObject args = config.getJSONObject("args");
    JSONObject playerResponse = args.getJSONObject("player_response");

    if (playerResponse.containsKey("videoDetails")) {
        JSONObject videoDetails = playerResponse.getJSONObject("videoDetails");
        String liveHLSUrl = null;
        if(videoDetails.getBooleanValue("isLive")) {
            if (playerResponse.containsKey("streamingData")) {
                liveHLSUrl = playerResponse.getJSONObject("streamingData").getString("hlsManifestUrl");
            }
        }
        return new VideoDetails(videoDetails, liveHLSUrl);
    }



    return new VideoDetails();
}
 
Example 2
public VideoDetails(JSONObject json, String liveHLSUrl) {
    videoId = json.getString("videoId");
    title = json.getString("title");
    lengthSeconds = json.getIntValue("lengthSeconds");
    keywords = json.containsKey("keywords") ? json.getJSONArray("keywords").toJavaList(String.class) : new ArrayList<String>();
    shortDescription = json.getString("shortDescription");
    JSONArray jsonThumbnails = json.getJSONObject("thumbnail").getJSONArray("thumbnails");
    thumbnails = new ArrayList<>(jsonThumbnails.size());
    for (int i = 0; i < jsonThumbnails.size(); i++) {
        JSONObject jsonObject = jsonThumbnails.getJSONObject(i);
        if (jsonObject.containsKey("url"))
            thumbnails.add(jsonObject.getString("url"));
    }
    averageRating = json.getIntValue("averageRating");
    viewCount = json.getLongValue("viewCount");
    author = json.getString("author");
    isLiveContent = json.getBooleanValue("isLiveContent");
    isLive = json.getBooleanValue("isLive");
    liveUrl = liveHLSUrl;
}
 
Example 3
Source Project: AndNet   File: CommParser.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Result<T> parse(String response) {
	Result<T> result = new Result<T>();
	try {
		JSONObject baseObject = JSON.parseObject(response);
		if(!baseObject.getBooleanValue("success")) {
			result.setMsg(baseObject.getString("message"));
		}else {
			Class<T> klass = Helper.generateType(getClass());
			if(klass == null) throw new Exception();
			
			T t = baseObject.getObject(mKey, klass);
			result.setStatus(Result.SUCCESS);
			result.setResult(t);
			return result;
		}
	} catch (Exception e) {
		e.printStackTrace();
		result.setMsg(Net.ERR_PARSE_MSG);
	}
	
	result.setStatus(Result.ERROR);
		return result;
}
 
Example 4
Source Project: DataLink   File: DSLSearchDocument.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 上传查询模板
 * @param vo
 * @return
 * @throws UnsupportedEncodingException
 */
public boolean uploadSearchTemplate(UploadSearchTemplate vo) throws UnsupportedEncodingException {
    Assert.notNull(vo, "DSLSearchVo is requeired");

    if(StringUtils.isBlank(vo.getTemplateName())) {
        throw new RuntimeException("查询模板的名称不能空");
    }
    byte [] bytes = vo.getContent().getBytes("utf-8");

    JSONObject json = JSONObject.parseObject(super.processRequest(vo, bytes));
    ProcessResult.checkError(json);
    if(json == null) {
        return false;
    }
    Boolean created = json.getBooleanValue(ParseHandler.CREATED_NAME);
    return created != null;
}
 
Example 5
/**
    * @return
    */
private Map<String, Set<String>> initAutoReadonlyFields() {
       Object[][] array = Application.createQueryNoFilter(
               "select actionContent from RobotTriggerConfig where (actionType = ? or actionType = ?) and isDisabled = 'F'")
               .setParameter(1, ActionType.FIELDAGGREGATION.name())
               .setParameter(2, ActionType.FIELDWRITEBACK.name())
               .array();

       CaseInsensitiveMap<String, Set<String>> fieldsMap = new CaseInsensitiveMap<>();
       for (Object[] o : array) {
           JSONObject content = JSON.parseObject((String) o[0]);
           if (content == null || !content.getBooleanValue("readonlyFields")) {
               continue;
           }

           String targetEntity = content.getString("targetEntity");
           targetEntity = targetEntity.split("\\.")[1];  // Field.Entity

           Set<String> fields = fieldsMap.computeIfAbsent(targetEntity, k -> new HashSet<>());
           for (Object item : content.getJSONArray("items")) {
               String targetField = ((JSONObject) item).getString("targetField");
               fields.add(targetField);
           }
       }

       Application.getCommonCache().putx(CKEY_TARF, fieldsMap);
       return fieldsMap;
   }
 
Example 6
Source Project: easyweb-shiro   File: JSONUtil.java    License: MIT License 5 votes vote down vote up
/**
 * 得到booleanValue类型的值
 */
public static boolean getBooleanValue(String json, String key) {
    boolean result = false;
    try {
        JSONObject jsonObject = JSON.parseObject(json);
        result = jsonObject.getBooleanValue(key);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
 
Example 7
/**
 * 是否为静默推送
 * 默认值为 false,及如果 server 并没有传 silent 字段,则默认为通知栏推送
 * @param message
 * @return
 */
static boolean getSilent(String message) {
  if (!StringUtil.isEmpty(message)) {
    try {
      JSONObject object = JSON.parseObject(message);
      return object.containsKey("silent")? object.getBooleanValue("silent"): false;
    } catch (JSONException e) {
      Log.e(TAG,"failed to parse JSON.", e);
    }
  }
  return false;
}
 
Example 8
/**
 * 是否为静默推送
 * 默认值为 false,及如果 server 并没有传 silent 字段,则默认为通知栏推送
 * @param message
 * @return
 */
static boolean getSilent(String message) {
  if (!StringUtil.isEmpty(message)) {
    try {
      JSONObject object = JSON.parseObject(message);
      return object.containsKey("silent")? object.getBooleanValue("silent"): false;
    } catch (JSONException e) {
      LOGGER.e("failed to parse JSON.", e);
    }
  }
  return false;
}
 
Example 9
/**
 * 根据主题获取kafka消费实例是否重新加载
 *
 * @param topic
 * @return
 */
public boolean getKafkaisReLoadConsmer(String topic) {
    boolean result = false;
    if (StringUtil.isBlank(topic)) {
        return result;
    }
    String key = ConstantUtil.CACHE_SYS_BASE_DATA_ + "getKafkaisReLoadConsmer" + topic;
    String redisCache = getCache(key);
    if (StringUtil.isNotBlank(redisCache)) {
        return result;
    }
    String dictValue = getDictValue(ConstantUtil.DICT_TYPE_CONFIG_KAFKA, topic);
    JSONObject jsonObject = null;
    try {
        jsonObject = JSONObject.parseObject(dictValue);
    } catch (Exception e) {
        logger.error(StringUtil.getExceptionMsg(e));
    }
    if (jsonObject == null) {
        return result;
    }
    result = jsonObject.getBooleanValue("isReloadKafka");
    if (result) {
        save(key, "false", 60 * 5);//五分钟内无需对同一个topic实例进行实例加载
    }
    return result;
}
 
Example 10
@Override
public String update(String index, String type, String id, Object json) {
	String uri = "/"+index+"/"+type+"/"+id;
	String result = base(uri, HttpUtil.METHOD_GET,null);
	JSONObject target = JSON.parseObject(result);
	if(target.getBooleanValue("found")){
		JSONObject body = JSON.parseObject(JSON.toJSONString(json));
		result = base(uri, HttpUtil.METHOD_PUT, body.toJSONString());
	}
	return result;
}
 
Example 11
@Override
public String update(String index, String type, String id, Object json) {
	String uri = "/"+index+"/"+type+"/"+id;
	String result = base(uri, HttpUtil.METHOD_GET,null);
	JSONObject target = JSON.parseObject(result);
	if(target.getBooleanValue("found")){
		JSONObject body = JSON.parseObject(JSON.toJSONString(json));
		result = base(uri, HttpUtil.METHOD_PUT, body.toJSONString());
	}
	return result;
}
 
Example 12
Source Project: tephra   File: TextImpl.java    License: MIT License 5 votes vote down vote up
private boolean hasTrue(JSONObject text, JSONObject paragraph, JSONObject word, String key) {
    if (word.containsKey(key))
        return word.getBooleanValue(key);

    if (paragraph.containsKey(key))
        return paragraph.getBooleanValue(key);

    if (text.containsKey(key))
        return text.getBooleanValue(key);

    return false;
}
 
Example 13
Source Project: zabbix-api   File: DefaultZabbixApi.java    License: Apache License 2.0 4 votes vote down vote up
public boolean hostExists(String name) {
	Request request = RequestBuilder.newBuilder().method("host.exists").paramEntry("name", name).build();
	JSONObject response = call(request);
	return response.getBooleanValue("result");
}
 
Example 14
Source Project: redtorch   File: AuthServiceImpl.java    License: MIT License 4 votes vote down vote up
@Override
public boolean login(String username, String password) {

	if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
		return false;
	}

	JSONObject reqDataJsonObject = new JSONObject();
	reqDataJsonObject.put("username", username);
	reqDataJsonObject.put("password", password);

	RestTemplate rest = new RestTemplate();
	HttpHeaders requestHeaders = new HttpHeaders();
	requestHeaders.add("Content-Type", "application/json");
	requestHeaders.add("Accept", "*/*");
	HttpEntity<String> requestEntity = new HttpEntity<String>(reqDataJsonObject.toJSONString(), requestHeaders);

	loginStatus = false;
	responseHttpHeaders = null;
	this.username = "";
	try {
		ResponseEntity<String> responseEntity = rest.exchange(loginUri, HttpMethod.POST, requestEntity, String.class);
		System.out.println(responseEntity.toString());
		if (responseEntity.getStatusCode().is2xxSuccessful()) {
			JSONObject resultJSONObject = JSON.parseObject(responseEntity.getBody());
			if (resultJSONObject.getBooleanValue("status")) {
				JSONObject voData = resultJSONObject.getJSONObject("voData");

				nodeId = voData.getInteger("recentlyNodeId");
				operatorId = voData.getString("operatorId");
				this.username = username;
				loginStatus = true;
				responseHttpHeaders = responseEntity.getHeaders();
				logger.info("登录成功!");
				return true;
			} else {
				logger.error("登录失败!服务器返回错误!");
				return false;
			}

		} else {
			logger.info("登录失败!");
			return false;
		}

	} catch (Exception e) {
		logger.error("登录请求错误!", e);
		return false;
	}
}
 
Example 15
Source Project: zabbix-api   File: DefaultZabbixApi.java    License: Apache License 2.0 4 votes vote down vote up
public boolean hostgroupExists(String name) {
	Request request = RequestBuilder.newBuilder().method("hostgroup.exists").paramEntry("name", name).build();
	JSONObject response = call(request);
	return response.getBooleanValue("result");
}
 
Example 16
Source Project: xian   File: ZkServiceAware.java    License: Apache License 2.0 4 votes vote down vote up
private static boolean isEnabled(JSONObject nodeData) {
    return nodeData.getBooleanValue("enabled");
}
 
Example 17
Source Project: jeecg   File: TimeTaskController.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 启动或者停止任务
 */
@RequestMapping(params = "startOrStopTask")
@ResponseBody
public AjaxJson startOrStopTask(TSTimeTaskEntity timeTask, HttpServletRequest request) {
	
	AjaxJson j = new AjaxJson();
	boolean isStart = timeTask.getIsStart().equals("1");
	timeTask = timeTaskService.get(TSTimeTaskEntity.class, timeTask.getId());		
	boolean isSuccess = false;
	
	if ("0".equals(timeTask.getIsEffect())) {
		j.setMsg("该任务为禁用状态,请解除禁用后重新启动");
		return j;
	}
	if (isStart && "1".equals(timeTask.getIsStart())) {
		j.setMsg("该任务当前已经启动,请停止后再试");
		return j;
	}
	if (!isStart && "0".equals(timeTask.getIsStart())) {
		j.setMsg("该任务当前已经停止,重复操作");
		return j;
	}
	//String serverIp = InetAddress.getLocalHost().getHostAddress();
	List<String> ipList = IpUtil.getLocalIPList();
	String runServerIp = timeTask.getRunServerIp();

	if((ipList.contains(runServerIp) || StringUtil.isEmpty(runServerIp) || "本地".equals(runServerIp)) && (runServerIp.equals(timeTask.getRunServer()))){//当前服务器IP匹配成功

		isSuccess = dynamicTask.startOrStop(timeTask ,isStart);	
	}else{
		try {
			String url = "http://"+timeTask.getRunServer()+"/timeTaskController.do?remoteTask";//spring-mvc.xml
			String param = "id="+timeTask.getId()+"&isStart="+(isStart ? "1" : "0");
			JSONObject json = HttpRequest.sendPost(url, param);
			isSuccess = json.getBooleanValue("success");
		} catch (Exception e) {
			j.setMsg("远程主机‘"+timeTask.getRunServer()+"’响应超时");
			return j;
		}
	}		
	j.setMsg(isSuccess?"定时任务管理更新成功":"定时任务管理更新失败");
	return j;
}
 
Example 18
Source Project: tephra   File: JsonImpl.java    License: MIT License 4 votes vote down vote up
@Override
public boolean hasTrue(JSONObject object, String key) {
    return containsKey(object, key) && object.getBooleanValue(key);
}
 
Example 19
@Override
public CRDResultVo parseData(JSONObject json) {
	
	CRDResultVo vo = new CRDResultVo();
	
	if(json == null) {
		return vo;
	}
	
	vo.setJsonString(json.toJSONString());
	
	boolean isCreate = json.getBooleanValue(CREATED_NAME);
	
	if(isCreate) {
		vo.setOperateType(ESEnum.OperateTypeEnum.CREATE);
	}else {
		vo.setOperateType(ESEnum.OperateTypeEnum.ALLUPDATE);
	}
	
	vo.setIndex(json.getString(INDEX_NAME));
	vo.setType(json.getString(TYPE_NAME));
	vo.setId(json.getString(ID_NAME));
	
	vo.setSuccess(true);
	
	return vo;
	
}
 
Example 20
Source Project: EserKnife   File: DeleteParseHandler.java    License: Apache License 2.0 3 votes vote down vote up
@Override
public CrdResultDetailVo parseData(JSONObject json) {

    CrdResultDetailVo vo = new CrdResultDetailVo();

    vo.setOperateType(OperateTypeEnum.DELETE);

    if(json == null) {
        return vo;
    }

    vo.setJsonString(json.toJSONString());

    boolean found = json.getBooleanValue(FOUND_NAME);

    if(found) {
        JSONObject shard = json.getJSONObject(SHARD_NAME);

        int failed = shard.getIntValue(FAILED_NAME);
        int success = shard.getIntValue(SUCCESS_NAME);

        if(success > 0 && failed == 0) {
            vo.setSuccess(true);
        }
    }

    vo.setIndex(json.getString(INDEX_NAME));
    vo.setType(json.getString(TYPE_NAME));
    vo.setId(json.getString(ID_NAME));

    return vo;

}