本文整理汇总了Java中net.sf.json.JSONNull.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java JSONNull.getInstance方法的具体用法?Java JSONNull.getInstance怎么用?Java JSONNull.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.json.JSONNull
的用法示例。
在下文中一共展示了JSONNull.getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: 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());
}
}
}
示例3: 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());
}