本文整理汇总了Java中com.fasterxml.jackson.databind.node.ArrayNode.add方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayNode.add方法的具体用法?Java ArrayNode.add怎么用?Java ArrayNode.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.node.ArrayNode
的用法示例。
在下文中一共展示了ArrayNode.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTypescriptConfig
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private void writeTypescriptConfig() throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
ObjectNode root = mapper.createObjectNode();
ObjectNode compilerOptions = root.putObject("compilerOptions");
compilerOptions.put("baseUrl", "");
compilerOptions.put("declaration", true);
compilerOptions.put("emitDecoratorMetadata", true);
compilerOptions.put("experimentalDecorators", true);
compilerOptions.put("module", "es6");
compilerOptions.put("moduleResolution", "node");
compilerOptions.put("sourceMap", true);
compilerOptions.put("target", "es5");
ArrayNode typeArrays = compilerOptions.putArray("typeRoots");
typeArrays.add("node_modules/@types");
ArrayNode libs = compilerOptions.putArray("lib");
libs.add("es6");
libs.add("dom");
File outputSourceDir = new File(outputDir, config.getSourceDirectoryName());
File file = new File(outputSourceDir, "tsconfig.json");
file.getParentFile().mkdirs();
mapper.writer().writeValue(file, root);
}
示例2: toJson
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
public JsonNode toJson() {
ObjectNode jsonRule = new ObjectMapper().createObjectNode();
jsonRule.put("ETag", this.eTag);
jsonRule.put("Id", this.id);
jsonRule.put("Name", this.name);
jsonRule.put("DateCreated", this.dateCreated);
jsonRule.put("DateModified", this.dateModified);
jsonRule.put("Enabled", this.enabled);
jsonRule.put("Description", this.description);
jsonRule.put("GroupId", this.groupId);
jsonRule.put("Severity", this.severity);
ArrayNode jsonConditions = jsonRule.putArray("Conditions");
for (ConditionServiceModel condition : this.conditions) {
ObjectNode jsonCondition = new ObjectMapper().createObjectNode();
jsonCondition.put("Field", condition.getField());
jsonCondition.put("Operator", condition.getOperator());
jsonCondition.put("Value", condition.getValue());
jsonConditions.add(jsonCondition);
}
return jsonRule;
}
示例3: getState
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
public JsonNode getState() {
ObjectMapper mapper = new ObjectMapper();
ObjectNode state = mapper.createObjectNode();
state.put("name", this.getClass().getSimpleName());
state.put("rows", this.rows);
state.put("columns", this.columns);
ArrayNode boardState = state.putArray("board");
int[][] board = this.getBoard();
for (int column = 0; column < this.columns; column++) {
ArrayNode columnState = boardState.addArray();
for (int row = 0; row < this.rows; row++) {
columnState.add(board[column][row]);
}
}
state.put("turn", this.currentPlayer);
state.put("ended", this.ended);
state.put("winner", this.winner);
return state;
}
示例4: addFulfillments
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private static void addFulfillments(final ObjectNode transactionEnvelopeNode, final List<KeyPair> keyPairs) {
final String canonicalString = JsonCanonicalizer.json2CanonicalString(transactionEnvelopeNode);
Ed25519Fulfillment fulfillment =
Ed25519Fulfillment.BuildFromSecrets(keyPairs.get(0), new MessagePayload(encodeUtf8(canonicalString)));
final ObjectNode fulfillmentNode = jsonNodeFactory.objectNode();
fulfillmentNode.set("fulfillment", jsonNodeFactory.textNode(fulfillment.toURI()));
fulfillmentNode.set("fulfills", jsonNodeFactory.nullNode());
final ArrayNode ownersBefore = jsonNodeFactory.arrayNode();
ownersBefore.add(jsonNodeFactory.textNode(Base58.base58Encode(keyPairs.get(0).getPublic().getEncoded())));
fulfillmentNode.set("owners_before", ownersBefore);
JsonNode fulfillments = transactionEnvelopeNode.get("inputs");
if (fulfillments == null || !fulfillments.isArray()) {
throw new RuntimeException("Badly structured transaction does not contain \"inputs\": " + transactionEnvelopeNode);
}
((ArrayNode) fulfillments).set(0, fulfillmentNode);
}
示例5: includeElementFieldWithWeight
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
public static void includeElementFieldWithWeight(String dbName, String field_name, String namespace, String elementName, double weight, String attrNS_URI, String attr_localname, String attr_value) throws Exception{
ObjectMapper mapper = new ObjectMapper();
// ObjectNode mainNode = mapper.createObjectNode();
ObjectNode childNode = mapper.createObjectNode();
ArrayNode arrNode = mapper.createArrayNode();
ObjectNode childNodeObject = mapper.createObjectNode();
childNodeObject.put( "namespace-uri", namespace);
childNodeObject.put( "localname", elementName);
childNodeObject.put("weight", weight);
// These 3 are new fields that have been added as of 8.0.2 from 03/20/2015 in the Management API.
childNodeObject.put( "attribute-namespace-uri", attrNS_URI);
childNodeObject.put( "attribute-localname", attr_localname);
childNodeObject.put( "attribute-value", attr_value);
arrNode.add(childNodeObject);
childNode.putArray("included-element").addAll(arrNode);
//System.out.println( childNode.toString());
setDatabaseFieldProperties(dbName,field_name,"included-element",childNode);
}
示例6: addGeospatialElementPairIndexes
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
public static void addGeospatialElementPairIndexes(String dbName,String parentNamespaceUri,String parentLocalName,String latNamespace,String latLocalname,String longNamespace,String longLocalname,String coordinateSystem,boolean rangeValuePositions,String invalidValues) throws Exception{
ObjectMapper mapper = new ObjectMapper();
// ObjectNode mainNode = mapper.createObjectNode();
ObjectNode childNode = mapper.createObjectNode();
ArrayNode childArray = mapper.createArrayNode();
ObjectNode childNodeObject = mapper.createObjectNode();
childNodeObject.put( "parent-namespace-uri", parentNamespaceUri);
childNodeObject.put( "parent-localname", parentLocalName);
childNodeObject.put( "latitude-namespace-uri", latNamespace);
childNodeObject.put( "latitude-localname", latLocalname);
childNodeObject.put( "longitude-namespace-uri", latNamespace);
childNodeObject.put( "longitude-localname", longLocalname);
childNodeObject.put( "coordinate-system", coordinateSystem);
childNodeObject.put("range-value-positions", false);
childNodeObject.put("invalid-values", invalidValues);
childArray.add(childNodeObject);
childNode.putArray("geospatial-element-pair-index").addAll(childArray);
// mainNode.put("geospatial-element-pair-indexes", childNode);
// System.out.println(type + mainNode.path("range-path-indexes").path("range-path-index").toString());
setDatabaseProperties(dbName,"geospatial-element-pair-index",childNode);
}
示例7: sendBootstrapData
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private void sendBootstrapData() {
ClusterService service = directory.get(ClusterService.class);
ArrayNode instances = mapper.createArrayNode();
for (ControllerNode node : service.getNodes()) {
ObjectNode instance = mapper.createObjectNode()
.put(ID, node.id().toString())
.put(IP, node.ip().toString())
.put(TopoConstants.Glyphs.UI_ATTACHED,
node.equals(service.getLocalNode()));
instances.add(instance);
}
ObjectNode payload = mapper.createObjectNode();
payload.set(CLUSTER_NODES, instances);
payload.put(USER, userName);
sendMessage(BOOTSTRAP, 0, payload);
}
示例8: getState
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
public JsonNode getState() {
ObjectMapper mapper = new ObjectMapper();
ObjectNode state = mapper.createObjectNode();
state.put("name", this.gameClass.getSimpleName());
ArrayNode rooms = state.putArray("rooms");
for (GameRoom room : this.rooms.values()) {
rooms.add(room.getState(false));
}
ArrayNode players = state.putArray("players");
for (GamePlayer player : this.players.values()) {
players.add(player.getState());
}
return state;
}
示例9: addGeoSpatialElementChildIndexes
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
public static void addGeoSpatialElementChildIndexes(String dbName,String parentNamespaceUri,String parentLocalName,String namespace,String localname,String coordinateSystem,String pointFormat,boolean rangeValuePositions,String invalidValues) throws Exception{
ObjectMapper mapper = new ObjectMapper();
// ObjectNode mainNode = mapper.createObjectNode();
ObjectNode childNode = mapper.createObjectNode();
ArrayNode childArray = mapper.createArrayNode();
ObjectNode childNodeObject = mapper.createObjectNode();
childNodeObject.put( "parent-namespace-uri", parentNamespaceUri);
childNodeObject.put( "parent-localname", parentLocalName);
childNodeObject.put( "namespace-uri", namespace);
childNodeObject.put( "localname", localname);
childNodeObject.put( "coordinate-system", coordinateSystem);
childNodeObject.put("range-value-positions", false);
childNodeObject.put("invalid-values", invalidValues);
childNodeObject.put("point-format",pointFormat);
childArray.add(childNodeObject);
childNode.putArray("geospatial-element-child-index").addAll(childArray);
// mainNode.put("geospatial-element-child-indexes", childNode);
// System.out.println(type + mainNode.path("range-path-indexes").path("range-path-index").toString());
setDatabaseProperties(dbName,"geospatial-element-child-index",childNode);
}
示例10: json
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
/**
* Translates the given property panel into JSON, for returning
* to the client.
*
* @param pp the property panel model
* @return JSON payload
*/
public static ObjectNode json(PropertyPanel pp) {
ObjectNode result = objectNode()
.put(TITLE, pp.title())
.put(TYPE, pp.typeId())
.put(ID, pp.id());
ObjectNode pnode = objectNode();
ArrayNode porder = arrayNode();
for (PropertyPanel.Prop p : pp.properties()) {
porder.add(p.key());
pnode.put(p.key(), p.value());
}
result.set(PROP_ORDER, porder);
result.set(PROPS, pnode);
ArrayNode buttons = arrayNode();
for (ButtonId b : pp.buttons()) {
buttons.add(b.id());
}
result.set(BUTTONS, buttons);
return result;
}
示例11: queryAllPath
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
/**
* Retrieve details of all paths created.
*
* @return 200 OK
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response queryAllPath() {
log.debug("Query all paths.");
Iterable<Tunnel> tunnels = get(PceService.class).queryAllPath();
ObjectNode result = mapper().createObjectNode();
ArrayNode pathEntry = result.putArray("paths");
if (tunnels != null) {
for (final Tunnel tunnel : tunnels) {
PcePath path = DefaultPcePath.builder().of(tunnel).build();
pathEntry.add(codec(PcePath.class).encode(path, this));
}
}
return ok(result.toString()).build();
}
示例12: resolveArrayNode
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private JsonNode resolveArrayNode(LogEvent event, JsonNode srcNode) {
ArrayNode dstNode = objectMapper.createArrayNode();
for (int nodeIndex = 0; nodeIndex < srcNode.size(); nodeIndex++) {
JsonNode srcChildNode = srcNode.get(nodeIndex);
JsonNode dstChildNode = resolveNode(event, srcChildNode);
if (dstChildNode != null) {
dstNode.add(dstChildNode);
}
}
return dstNode.size() > 0 ? dstNode : null;
}
示例13: twoHostsOneDeviceSelected
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private ObjectNode twoHostsOneDeviceSelected() {
ObjectNode payload = objectNode();
ArrayNode ids = arrayNode();
payload.set(IDS, ids);
ids.add(HOST_A_ID.toString());
ids.add(DEVICE_1_ID.toString());
ids.add(HOST_B_ID.toString());
return payload;
}
示例14: userJsonArray
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private ArrayNode userJsonArray() {
ArrayNode userList = arrayNode();
for (SubscriberUser user: userMap.values()) {
userList.add(UserFactory.toObjectNode(user));
}
return userList;
}
示例15: json
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类
private Object json(ObjectMapper mapper, boolean isSuccess, ArrayList<Long> elapsed) {
ObjectNode result = mapper.createObjectNode();
result.put("Success", isSuccess);
ArrayNode node = result.putArray("elapsed-time");
for (Long v : elapsed) {
node.add(v);
}
return result;
}