本文整理汇总了Java中javax.json.JsonObject.getJsonObject方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.getJsonObject方法的具体用法?Java JsonObject.getJsonObject怎么用?Java JsonObject.getJsonObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.getJsonObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: about
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public Authenticated about() throws IOException {
final JsonArray online = this.server.storage().build()
.getJsonArray("authenticated");
for(int idx = 0; idx < online.size(); idx++) {
final JsonObject user = online.getJsonObject(idx);
if (user.getJsonObject(this.username) != null) {
return new MkJsonAuthenticated(
user.getJsonObject(this.username)
);
}
}
throw new IllegalStateException(
"User " + this.username + " is not logged in!"
);
}
示例2: navigationNext
import javax.json.JsonObject; //导入方法依赖的package包/类
/**
* Check json has navigation next link.
* @return True if json has navigation next link,
* Else if json hasn't navigation next link
*/
private boolean navigationNext() {
final AtomicBoolean next = new AtomicBoolean(false);
final JsonObject data;
try {
data = this.temp.get()
.json()
.getJsonObject("data");
} catch (final IOException error) {
throw new UncheckedIOException(error);
}
try {
final JsonObject navigation = data.getJsonObject("navigation");
next.set(navigation != null
&& navigation
.getString("next", null) != null);
} catch (final ClassCastException exception) {
// Do nothing
}
return next.get();
}
示例3: updateSensor
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public void updateSensor(JsonObject obj) throws UpdateException {
try {
setName(obj.getString("name"));
JsonObject state = obj.getJsonObject("state");
int t = state.getInt("temperature");
BigDecimal temp = new BigDecimal(t).movePointLeft(2);
SimpleDateFormat sdf = new SimpleDateFormat(Constants.HUEDATEFORMAT);
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Date time = sdf.parse(state.getString("lastupdated"));
SensorValue<BigDecimal> val = new SensorValue<>(time, temp);
updateValue(val);
JsonObject conf = obj.getJsonObject("config");
setOn(conf.getBoolean("on"));
setBattery(conf.getInt("battery"));
setReachable(conf.getBoolean("reachable"));
} catch (ParseException | NullPointerException | ClassCastException ex) {
throw new UpdateException("Error updating temp sensor", ex);
}
}
示例4: Browser
import javax.json.JsonObject; //导入方法依赖的package包/类
/**
* Constructs a new Browser from a Json object containing all the needed information
* and 'translate' to appropriate name of platform.
*
* @param jsonObject Json object obtained from the configuration file.
*/
public Browser(JsonObject jsonObject) {
String browserName = jsonObject.getString("browserName");
String browserVersion = "?";
String browserPlatform = "?";
if (jsonObject.get("version") != null) {
browserVersion = processVersion(jsonObject.getString("version"));
}
if (jsonObject.get("mobile") != null){
JsonObject mobile = jsonObject.getJsonObject("mobile");
browserPlatform = mobile.getString("platformName");
} else {
if (browserName.equalsIgnoreCase("MicrosoftEdge"))
browserPlatform = "Windows 10";
else
browserPlatform = processPlatform(jsonObject.getString("platform"));
}
this.name = browserName;
this.version = browserVersion;
this.platform = browserPlatform;
}
示例5: createAceOrderTestFolderWithOneAce
import javax.json.JsonObject; //导入方法依赖的package包/类
/**
* Helper to create a test folder with a single ACE pre-created
*/
private void createAceOrderTestFolderWithOneAce() throws IOException, JsonException {
testUserId = H.createTestUser();
testFolderUrl = H.createTestFolder();
addOrUpdateAce(testFolderUrl, testUserId, true, null);
//fetch the JSON for the acl to verify the settings.
String getUrl = testFolderUrl + ".acl.json";
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
JsonObject jsonObject = JsonUtil.parseObject(json);
assertEquals(1, jsonObject.size());
JsonObject user = jsonObject.getJsonObject(testUserId);
assertNotNull(user);
assertEquals(testUserId, user.getString("principal"));
assertEquals(0, user.getInt("order"));
}
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:27,代码来源:ModifyAceTest.java
示例6: DeltaAnalysisResult
import javax.json.JsonObject; //导入方法依赖的package包/类
public DeltaAnalysisResult(final Commits commits, final JsonObject result) {
ensureTheVersionIsSupported(result);
final JsonObject deltaResult = result.getJsonObject("result");
viewUrl = result.getString("view");
risk = riskFrom(deltaResult);
warnings = warningsFrom(deltaResult);
this.commits = commits;
}
示例7: processData
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public void processData(List<String> jsonData) {
for (Iterator<String> iterator = jsonData.iterator(); iterator.hasNext();) {
String jsonStr = iterator.next();
JsonReader jsonReader = Json.createReader(new StringReader(jsonStr));
try {
JsonObject jsonObject = jsonReader.readObject();
String topicName = jsonObject.getString("topic", null);
if (topicName != null) {
if (topicName.equals("http")) {
JsonObject payload = jsonObject.getJsonObject("payload");
long requestTime = payload.getJsonNumber("time").longValue();
long requestDuration = payload.getJsonNumber("duration").longValue();
String requestUrl = payload.getString("url", "");
synchronized (aggregateHttpData) {
aggregateHttpData.aggregate(requestTime, requestDuration, requestUrl);
}
} else {
emit(jsonObject.toString());
}
}
} catch (JsonException je) {
// Skip this object, log the exception and keep trying with
// the rest of the list
je.printStackTrace();
}
}
emitHttp();
}
示例8: testAddAceOrderByFirst
import javax.json.JsonObject; //导入方法依赖的package包/类
/**
* Test to verify adding an ACE in the first position of
* the ACL
*/
@Test
public void testAddAceOrderByFirst() throws IOException, JsonException {
createAceOrderTestFolderWithOneAce();
testGroupId = H.createTestGroup();
addOrUpdateAce(testFolderUrl, testGroupId, true, "first");
//fetch the JSON for the acl to verify the settings.
String getUrl = testFolderUrl + ".acl.json";
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
JsonObject jsonObject = JsonUtil.parseObject(json);
assertEquals(2, jsonObject.size());
JsonObject group = jsonObject.getJsonObject(testGroupId);
assertNotNull(group);
assertEquals(testGroupId, group.getString("principal"));
assertEquals(0, group.getInt("order"));
JsonObject user = jsonObject.getJsonObject(testUserId);
assertNotNull(user);
assertEquals(testUserId, user.getString("principal"));
assertEquals(1, user.getInt("order"));
}
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:32,代码来源:ModifyAceTest.java
示例9: testAddAceOrderByAfter
import javax.json.JsonObject; //导入方法依赖的package包/类
/**
* Test to verify adding an ACE after an existing ACE
* the ACL
*/
@Test
public void testAddAceOrderByAfter() throws IOException, JsonException {
createAceOrderTestFolderWithOneAce();
testGroupId = H.createTestGroup();
addOrUpdateAce(testFolderUrl, testGroupId, true, "after " + testUserId);
//fetch the JSON for the acl to verify the settings.
String getUrl = testFolderUrl + ".acl.json";
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
JsonObject jsonObject = JsonUtil.parseObject(json);
assertEquals(2, jsonObject.size());
JsonObject user = jsonObject.getJsonObject(testUserId);
assertNotNull(user);
assertEquals(testUserId, user.getString("principal"));
assertEquals(0, user.getInt("order"));
JsonObject group = jsonObject.getJsonObject(testGroupId);
assertNotNull(group);
assertEquals(testGroupId, group.getString("principal"));
assertEquals(1, group.getInt("order"));
}
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:33,代码来源:ModifyAceTest.java
示例10: parseAddress
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public Address parseAddress(JsonObject json) {
JsonObject result = json.getJsonObject("response").getJsonObject("data");
if (result != null) {
Address address = new Address();
if (result.getJsonObject("street_number") != null) {
address.setHouse(result.getJsonObject("street_number").getString("name"));
}
if (result.getJsonObject("street_name") != null) {
address.setStreet(result.getJsonObject("street_name").getString("name"));
}
if (result.getJsonObject("locality") != null) {
address.setSettlement(result.getJsonObject("locality").getString("name"));
}
if (result.getJsonObject("county") != null) {
address.setDistrict(result.getJsonObject("county").getString("name"));
}
if (result.getJsonObject("region") != null) {
address.setState(result.getJsonObject("region").getString("name"));
}
if (result.getJsonObject("country") != null) {
address.setCountry(result.getJsonObject("country").getString("name"));
}
if (result.getJsonObject("postcode") != null) {
address.setPostcode(result.getJsonObject("postcode").getString("name"));
}
return address;
}
return null;
}
示例11: checkForJSErrors
import javax.json.JsonObject; //导入方法依赖的package包/类
public void checkForJSErrors(JsonObject response) {
if (response.getBoolean("wasThrown")) {
JsonObject details = response.getJsonObject("result");
String desc = details.getString("description");
throw new WebDriverException("JS error :" + desc);
}
}
示例12: handle
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public Response handle() throws Exception {
JsonObject payload = getRequest().getPayload();
JsonObject cookie = payload.getJsonObject("cookie");
String name = cookie.getString("name", "");
String value = cookie.getString("value", "");
String path = cookie.getString("path", "/");
String domain;
if (cookie.containsKey("domain")) {
domain = cookie.getString("domain");
} else {
URL url = new URL(getWebDriver().getCurrentUrl());
domain = url.getHost();
}
boolean secure = cookie.getBoolean("secure", false);
boolean httpOnly = cookie.getBoolean("httpOnly", false);
Instant expiry =
cookie.containsKey("expiry")
? Instant.ofEpochSecond(cookie.getJsonNumber("expiry").longValueExact())
: OffsetDateTime.now(ZoneOffset.UTC).plusYears(20).toInstant();
getWebDriver().addCookie(name, value, path, domain, secure, httpOnly, expiry);
Response res = new Response();
res.setSessionId(getSession().getSessionId());
res.setStatus(0);
return res;
}
示例13: testEffectiveAclMergeForUser_MorePrivilegesGrantedOnChild
import javax.json.JsonObject; //导入方法依赖的package包/类
/**
* Test for SLING-2600, Effective ACL servlet returns incorrect information
*/
@Test
public void testEffectiveAclMergeForUser_MorePrivilegesGrantedOnChild() throws IOException, JsonException {
testUserId = H.createTestUser();
String testFolderUrl = H.createTestFolder("{ \"jcr:primaryType\": \"nt:unstructured\", \"propOne\" : \"propOneValue\", \"child\" : { \"childPropOne\" : true } }");
String postUrl = testFolderUrl + ".modifyAce.html";
//1. create an initial set of privileges
List<NameValuePair> postParams = new ArrayList<NameValuePair>();
postParams.add(new NameValuePair("principalId", testUserId));
postParams.add(new NameValuePair("[email protected]:write", "granted"));
Credentials creds = new UsernamePasswordCredentials("admin", "admin");
H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
postParams = new ArrayList<NameValuePair>();
postParams.add(new NameValuePair("principalId", testUserId));
postParams.add(new NameValuePair("[email protected]:all", "granted"));
postUrl = testFolderUrl + "/child.modifyAce.html";
H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
//fetch the JSON for the eacl to verify the settings.
String getUrl = testFolderUrl + "/child.eacl.json";
String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
assertNotNull(json);
JsonObject jsonObject = JsonUtil.parseObject(json);
JsonObject aceObject = jsonObject.getJsonObject(testUserId);
assertNotNull(aceObject);
String principalString = aceObject.getString("principal");
assertEquals(testUserId, principalString);
JsonArray grantedArray = aceObject.getJsonArray("granted");
assertNotNull(grantedArray);
assertEquals(1, grantedArray.size());
Set<String> grantedPrivilegeNames = new HashSet<String>();
for (int i=0; i < grantedArray.size(); i++) {
grantedPrivilegeNames.add(grantedArray.getString(i));
}
H.assertPrivilege(grantedPrivilegeNames,true,"jcr:all");
Object deniedArray = aceObject.get("denied");
assertNull(deniedArray);
}
示例14: OrderAccepted
import javax.json.JsonObject; //导入方法依赖的package包/类
public OrderAccepted(JsonObject jsonObject) {
this(new OrderInfo(jsonObject.getJsonObject("orderInfo")), Instant.parse(jsonObject.getString("instant")));
}
示例15: CoffeeBrewStarted
import javax.json.JsonObject; //导入方法依赖的package包/类
public CoffeeBrewStarted(JsonObject jsonObject) {
this(new OrderInfo(jsonObject.getJsonObject("orderInfo")), Instant.parse(jsonObject.getString("instant")));
}