List of usage examples for com.fasterxml.jackson.databind.node ArrayNode size
public int size()
From source file:org.pac4j.oauth.profile.foursquare.FoursquareUserFriends.java
@Override protected void buildFromJson(JsonNode json) { count = json.get("count").asInt(); ArrayNode groupsArray = (ArrayNode) json.get("groups"); for (int i = 0; i < groupsArray.size(); i++) { FoursquareUserFriendGroup group = new FoursquareUserFriendGroup(); group.buildFromJson(groupsArray.get(i)); groups.add(group);// w w w . j ava 2 s .c o m } }
From source file:org.gitana.platform.client.log.LogThrowable.java
public List<LogStackTraceElement> getStackTrace() { List<LogStackTraceElement> stacktrace = new ArrayList<LogStackTraceElement>(); ArrayNode array = (ArrayNode) getObject().get(FIELD_STACKTRACE); for (int i = 0; i < array.size(); i++) { ObjectNode object = (ObjectNode) array.get(i); stacktrace.add(new LogStackTraceElement(object)); }//from ww w .ja v a 2s. c om return stacktrace; }
From source file:org.pac4j.oauth.profile.foursquare.FoursquareUserFriendGroup.java
@Override protected void buildFromJson(JsonNode json) { count = json.get("count").asInt(); name = json.get("name").asText(); type = json.get("type").asText(); ArrayNode groupsArray = (ArrayNode) json.get("items"); for (int i = 0; i < groupsArray.size(); i++) { FoursquareUserFriend friend = new FoursquareUserFriend(); friend.buildFromJson(groupsArray.get(i)); friends.add(friend);/*from w ww. ja v a2 s. com*/ } }
From source file:com.redhat.lightblue.crud.validator.ArraySizeCheckerTest.java
@Test public void testCheckConstraint_TooLarge() { ConstraintValidator validator = mock(ConstraintValidator.class); ArraySizeConstraint constraint = new ArraySizeConstraint("Fake Type"); constraint.setValue(2);//from w w w. ja v a 2 s .c om ArrayNode fieldValue = mock(ArrayNode.class); when(fieldValue.size()).thenReturn(3); new ArraySizeChecker().checkConstraint(validator, null, null, constraint, null, null, fieldValue); verify(validator, times(1)).addDocError(any(Error.class)); }
From source file:com.redhat.lightblue.crud.validator.ArraySizeCheckerTest.java
@Test public void testCheckConstraint_NotMin_NoErrors() { ConstraintValidator validator = mock(ConstraintValidator.class); ArraySizeConstraint constraint = new ArraySizeConstraint("Fake Type"); constraint.setValue(2);//from ww w . j a v a 2 s.c om ArrayNode fieldValue = mock(ArrayNode.class); when(fieldValue.size()).thenReturn(1); new ArraySizeChecker().checkConstraint(validator, null, null, constraint, null, null, fieldValue); verify(validator, never()).addDocError(any(Error.class)); }
From source file:com.redhat.lightblue.crud.validator.ArraySizeCheckerTest.java
@Test public void testCheckConstraint_Min_TooSmall() { ConstraintValidator validator = mock(ConstraintValidator.class); ArraySizeConstraint constraint = new ArraySizeConstraint(ArraySizeConstraint.MIN); constraint.setValue(2);//from ww w . j a va 2 s . c om ArrayNode fieldValue = mock(ArrayNode.class); when(fieldValue.size()).thenReturn(1); new ArraySizeChecker().checkConstraint(validator, null, null, constraint, null, null, fieldValue); verify(validator, times(1)).addDocError(any(Error.class)); }
From source file:com.redhat.lightblue.crud.validator.ArraySizeCheckerTest.java
@Test public void testCheckConstraint_Min_NoErrors() { ConstraintValidator validator = mock(ConstraintValidator.class); ArraySizeConstraint constraint = new ArraySizeConstraint(ArraySizeConstraint.MIN); constraint.setValue(2);/*from w w w .j av a 2 s . c om*/ ArrayNode fieldValue = mock(ArrayNode.class); when(fieldValue.size()).thenReturn(3); new ArraySizeChecker().checkConstraint(validator, null, null, constraint, null, null, fieldValue); verify(validator, never()).addDocError(any(Error.class)); }
From source file:com.mapr.data.sputnik.util.JsonUtils.java
public void flattenJsonIntoMap(String currentPath, JsonNode jsonNode, Map<String, Object> map) { if (jsonNode.isObject()) { ObjectNode objectNode = (ObjectNode) jsonNode; Iterator<Map.Entry<String, JsonNode>> iter = objectNode.fields(); String pathPrefix = currentPath.isEmpty() ? "" : currentPath + "."; while (iter.hasNext()) { Map.Entry<String, JsonNode> entry = iter.next(); flattenJsonIntoMap(pathPrefix + entry.getKey(), entry.getValue(), map); }//from ww w.j a v a 2s. c o m } else if (jsonNode.isArray()) { ArrayNode arrayNode = (ArrayNode) jsonNode; for (int i = 0; i < arrayNode.size(); i++) { flattenJsonIntoMap(currentPath + "[" + i + "]", arrayNode.get(i), map); } } else if (jsonNode.isValueNode()) { ValueNode valueNode = (ValueNode) jsonNode; Object value = null; if (valueNode.isNumber()) { value = valueNode.numberValue(); } else if (valueNode.isBoolean()) { value = valueNode.asBoolean(); } else if (valueNode.isTextual()) { value = valueNode.asText(); } map.put(currentPath, value); } }
From source file:com.centurylink.cloud.sdk.policy.services.client.domain.ActionSettingsDeserializer.java
@Override public ActionSettingsMetadata deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { TreeNode node = jsonParser.getCodec().readTree(jsonParser); //email settings if (node.get(RECIPIENTS).isArray()) { ArrayNode recipientsNode = ((ArrayNode) node.get(RECIPIENTS)); List<String> recipients = new ArrayList<>(recipientsNode.size()); recipientsNode.forEach(recipient -> recipients.add(recipient.asText())); return new ActionSettingsEmailMetadata().recipients(recipients); }/*from www . j a v a 2 s .co m*/ return null; }
From source file:org.gitana.platform.client.permission.PermissionCheckResults.java
public synchronized Map<String, PermissionCheckResult> map() { if (map == null) { Map<String, PermissionCheckResult> theMap = new HashMap<String, PermissionCheckResult>(); ArrayNode array = (ArrayNode) getObject().get("results"); for (int i = 0; i < array.size(); i++) { ObjectNode object = (ObjectNode) array.get(i); PermissionCheckResult result = new PermissionCheckResult(object); String key = result.getPermissionedId() + "_" + result.getPrincipalId() + "_" + result.getPermissionId(); theMap.put(key, result);// w w w .ja v a2 s . c o m } map = theMap; } return map; }