• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JSONNull类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.sf.json.JSONNull的典型用法代码示例。如果您正苦于以下问题:Java JSONNull类的具体用法?Java JSONNull怎么用?Java JSONNull使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JSONNull类属于net.sf.json包,在下文中一共展示了JSONNull类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

import net.sf.json.JSONNull; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void execute() {
    JSONObject postDifferentialCommentResult = postDifferentialComment(comment, SILENT,
            commentAction);
    if (postDifferentialCommentResult == null ||
            !(postDifferentialCommentResult.get("error_info") instanceof JSONNull)) {
        if (postDifferentialCommentResult != null) {
            info(String.format("Got error %s with action %s",
                    postDifferentialCommentResult.get("error_info"), commentAction));
        }

        info("Re-trying with action 'none'");
        postDifferentialComment(comment, SILENT, DEFAULT_COMMENT_ACTION);
    }
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:19,代码来源:PostCommentTask.java


示例2: getParentCoverage

import net.sf.json.JSONNull; //导入依赖的package包/类
public CodeCoverageMetrics getParentCoverage(String sha) {
    if (sha == null) {
        return null;
    }
    try {
        String coverageJSON = getCoverage(sha);
        JsonSlurper jsonParser = new JsonSlurper();
        JSON responseJSON = jsonParser.parseText(coverageJSON);
        if (responseJSON instanceof JSONNull) {
            return null;
        }
        JSONObject coverage = (JSONObject) responseJSON;

        return new CodeCoverageMetrics(
                ((Double) coverage.getDouble(PACKAGE_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(FILES_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(CLASSES_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(METHOD_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(LINE_COVERAGE_KEY)).floatValue(),
                ((Double) coverage.getDouble(CONDITIONAL_COVERAGE_KEY)).floatValue());
    } catch (Exception e) {
        e.printStackTrace(logger.getStream());
    }

    return null;
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:27,代码来源:UberallsClient.java


示例3: test_for_issue

import net.sf.json.JSONNull; //导入依赖的package包/类
public void test_for_issue() throws Exception {

        Model model = new Model();
        model.object = JSONNull.getInstance();
        System.out.println(JSON.toJSONString(model));
//        System.out.println(JSON.toJSONString(map));
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Issue997.java


示例4: query

import net.sf.json.JSONNull; //导入依赖的package包/类
/**
 * Execute Http request and response code
 * @param request - HTTP Request
 * @param expectedCode - expected response code
 * @return - response in JSONObject
 */
public JSON query(HttpRequestBase request, int expectedCode) throws IOException {
    log.info("Requesting: " + request);
    addRequiredHeader(request);

    HttpParams requestParams = request.getParams();
    requestParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, TIMEOUT * 1000);
    requestParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, TIMEOUT * 1000);

    synchronized (httpClient) {
        String response;
        try {
            HttpResponse result = httpClient.execute(request);

            int statusCode = result.getStatusLine().getStatusCode();

            response = getResponseEntity(result);

            if (statusCode != expectedCode) {

                notifier.notifyAbout("Response with code " + statusCode + ": " + extractErrorMessage(response));
                throw new IOException("API responded with wrong status code: " + statusCode);
            } else {
                log.debug("Response: " + response);
            }
        } finally {
            request.abort();
        }

        if (response == null || response.isEmpty()) {
            return JSONNull.getInstance();
        } else {
            return JSONSerializer.toJSON(response, new JsonConfig());
        }
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:42,代码来源:HttpUtils.java


示例5: sendMessage

import net.sf.json.JSONNull; //导入依赖的package包/类
/**
 * Try to send a message to harbormaster
 * @param unitResults the unit testing results to send
 * @param coverage the coverage data to send
 * @return false if an error was encountered
 */
private boolean sendMessage(UnitResults unitResults, Map<String, String> coverage, LintResults lintResults) throws IOException, ConduitAPIException {
    JSONObject result = diffClient.sendHarbormasterMessage(phid, harbormasterSuccess, unitResults, coverage, lintResults);

    if (result.containsKey("error_info") && !(result.get("error_info") instanceof JSONNull)) {
        info(String.format("Error from Harbormaster: %s", result.getString("error_info")));
        failTask();
        return false;
    } else {
        this.result = Result.SUCCESS;
    }
    return true;
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:19,代码来源:SendHarbormasterResultTask.java


示例6: getBranch

import net.sf.json.JSONNull; //导入依赖的package包/类
/**
 * Return the local branch name
 *
 * @return the name of the branch, or unknown
 */
public String getBranch() {
    Object branchName = rawJSON.get("branch");
    if (branchName instanceof JSONNull) {
        return "(none)";
    }
    try {
        return (String) branchName;
    } catch (ClassCastException e) {
        return "(unknown)";
    }
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:17,代码来源:Differential.java


示例7: testGetBranchWithEmptyResponse

import net.sf.json.JSONNull; //导入依赖的package包/类
@Test
public void testGetBranchWithEmptyResponse() throws Exception {
    JSONObject empty = new JSONObject();
    empty.put("branch", JSONNull.getInstance());
    Differential diff = new Differential(empty);
    assertEquals("(none)", diff.getBranch());
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:8,代码来源:DifferentialTest.java


示例8: put

import net.sf.json.JSONNull; //导入依赖的package包/类
public final MapTuple put(final String field, final @Nullable Object obj) {
  if (obj == null) {
    /*
     * We need this because of joins.  We don't use Java null because
     * too many libraries either return null to represent absence,
     * don't allow null entries, or use null to represent something else.
     */
    _values.put(field, JSONNull.getInstance());
  } else {
    _values.put(field, obj);
  }
  return this;  // for chaining
}
 
开发者ID:zillabyte,项目名称:motherbrain,代码行数:14,代码来源:MapTuple.java


示例9: removeNulls

import net.sf.json.JSONNull; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void removeNulls(JSONObject json) {
  Iterator<String> keyIter = json.keys();
  while(keyIter.hasNext()) {
    String key = keyIter.next().toString();
    if (json.get(key) instanceof JSONNull || json.get(key) == null) {
      json.remove(key);
    }
  }
}
 
开发者ID:zillabyte,项目名称:motherbrain,代码行数:11,代码来源:JSONUtil.java


示例10: parseObj

import net.sf.json.JSONNull; //导入依赖的package包/类
public static JSONObject parseObj(String o) {
  JSON j = JSONSerializer.toJSON(o);
  if (j instanceof JSONNull) {
    return null;
  } else {
    return (JSONObject)j;
  }
}
 
开发者ID:zillabyte,项目名称:motherbrain,代码行数:9,代码来源:JSONUtil.java


示例11: parseArray

import net.sf.json.JSONNull; //导入依赖的package包/类
public static JSONArray parseArray(String o) {
  JSON j = JSONSerializer.toJSON(o);
  if (j instanceof JSONNull) {
    return null;
  } else {
    return (JSONArray)j;
  }
}
 
开发者ID:zillabyte,项目名称:motherbrain,代码行数:9,代码来源:JSONUtil.java


示例12: getStringForType

import net.sf.json.JSONNull; //导入依赖的package包/类
public static String getStringForType(Object value) {
  if(value instanceof String) {
    return "\""+ StringEscapeUtils.escapeJson((String)value) +"\"";
  } else if(value instanceof Integer || value instanceof Float || value instanceof Long || value instanceof Boolean) {
    return value.toString();
  } else if(value instanceof JSONArray) {
    return JSONUtil.toString((JSONArray) value);
  } else if(value instanceof JSONObject) {
    return JSONUtil.toString((JSONObject) value);
  } else if(value instanceof JSONNull || value == null) {
    return "null";
  } else {
    throw new RuntimeException("unrecognized type for value: "+value+"["+value.getClass().getName()+"]");
  }
}
 
开发者ID:zillabyte,项目名称:motherbrain,代码行数:16,代码来源:JSONUtil.java


示例13: configure

import net.sf.json.JSONNull; //导入依赖的package包/类
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
	// To persist global configuration information,
	// set that to properties and call save().
	Object identities = formData.get("chefIdentity");
	if (!JSONNull.getInstance().equals(identities)) {
		chefIdentities = req.bindJSONToList(ChefIdentity.class, identities);
	} else {
		chefIdentities = null;
	}

	save();
	return super.configure(req,formData);
}
 
开发者ID:jenkinsci,项目名称:chef-identity-plugin,代码行数:15,代码来源:ChefIdentityBuildWrapper.java


示例14: configure

import net.sf.json.JSONNull; //导入依赖的package包/类
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
	Object s = json.get("servers");
	if (!JSONNull.getInstance().equals(s)) {
		servers = req.bindJSONToList(Server.class, s);
	} else {
		servers = null;
	}

	publicKeyPath = json.getString("publicKeyPath");
	save();
	return super.configure(req, json);
}
 
开发者ID:jenkinsci,项目名称:openshift-deployer-plugin,代码行数:14,代码来源:DeployApplication.java


示例15: convertElement

import net.sf.json.JSONNull; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public Vertex convertElement(Object json, Network network) {
	try {
		if (json == null) {
			return null;
		}
		Vertex object = null;
		if (json instanceof JSONObject) {
			object = network.createVertex();
			for (Iterator iterator = ((JSONObject)json).keys(); iterator.hasNext(); ) {
				String name = (String)iterator.next();
				Object value = ((JSONObject)json).get(name);
				if (value == null) {
					continue;
				}
				Primitive key = new Primitive(name);
				Vertex target = convertElement(value, network);
				object.addRelationship(key, target);
			}
		} else if (json instanceof JSONArray) {
			object = network.createInstance(Primitive.ARRAY);
			JSONArray array = (JSONArray)json;
			for (int index = 0; index < array.size(); index++) {
				Vertex element = convertElement(array.get(index), network);
				object.addRelationship(Primitive.ELEMENT, element, index);
			}
		} else if (json instanceof JSONNull) {
			object = network.createInstance(Primitive.NULL);
		} else if (json instanceof String) {
			object = network.createVertex(json);
		} else if (json instanceof Number) {
			object = network.createVertex(json);
		} else if (json instanceof Date) {
			object = network.createVertex(json);
		} else if (json instanceof Boolean) {
			object = network.createVertex(json);
		} else {
			log("Unknown JSON object", Level.INFO, json);
		}
		return object;
	} catch (Exception exception) {
		log(exception);
		return null;
	}
}
 
开发者ID:BotLibre,项目名称:BotLibre,代码行数:46,代码来源:Http.java


示例16: ValueTuple

import net.sf.json.JSONNull; //导入依赖的package包/类
/**
 * Initialises the value tuple.
 *
 * @param type
 * @param value
 */
public ValueTuple(String type, Object value) {
    this.type = type;
    this.value = (value != null ? value : JSONNull.getInstance());
}
 
开发者ID:rcarz,项目名称:jira-client,代码行数:11,代码来源:Field.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ColumnListMutation类代码示例发布时间:2022-05-21
下一篇:
Java LPARAM类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap