本文整理匯總了Java中com.fasterxml.jackson.databind.node.ObjectNode.put方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectNode.put方法的具體用法?Java ObjectNode.put怎麽用?Java ObjectNode.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.databind.node.ObjectNode
的用法示例。
在下文中一共展示了ObjectNode.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createOAuth
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private void createOAuth() throws IOException
{
token = requestToken(OAUTH_CLIENT_ID);
ObjectNode oauthclient = mapper.createObjectNode();
oauthclient.put("name", "Random OAuth");
oauthclient.put("clientId", "clientId");
oauthclient.put("clientSecret", "clientSecret");
oauthclient.put("userId", RestTestConstants.USERID_AUTOTEST);
oauthclient.put("redirectUrl", "default");
HttpResponse response = postEntity(oauthclient.toString(), context.getBaseUrl() + "api/oauth", token, true);
assertResponse(response, 201, "Expected oauthclient to be created");
oauthUri = response.getFirstHeader("Location").getValue();
getEntity(oauthUri, token);
}
示例2: getDockerTemplate
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@GetMapping ( value = "/serviceDockerTemplate" , produces = MediaType.APPLICATION_JSON_VALUE )
public JsonNode getDockerTemplate (
String templateName )
throws IOException {
// templateName = DockerJson.defaultJavaDocker.key
ObjectNode dockerTemplate = (ObjectNode) dockerHelper.getDockerTemplates().get( templateName );
String imageName = dockerTemplate.get( "image" ).asText().replaceAll(
Matcher.quoteReplacement( CSAP.DOCKER_REPOSITORY ),
Matcher.quoteReplacement( csapApp.getCsapCoreService().getDocker().getTemplateRepository() ) );
dockerTemplate.put( "image", imageName );
return dockerTemplate;
}
示例3: json
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
* Produces JSON object for an AS path.
*
* @param mapper the JSON object mapper to use
* @param asPath the AS path with the data
* @return JSON object for the AS path
*/
private ObjectNode json(ObjectMapper mapper, BgpRouteEntry.AsPath asPath) {
ObjectNode result = mapper.createObjectNode();
ArrayNode pathSegmentsJson = mapper.createArrayNode();
for (BgpRouteEntry.PathSegment pathSegment : asPath.getPathSegments()) {
ObjectNode pathSegmentJson = mapper.createObjectNode();
pathSegmentJson.put("type",
BgpConstants.Update.AsPath.typeToString(pathSegment.getType()));
ArrayNode segmentAsNumbersJson = mapper.createArrayNode();
for (Long asNumber : pathSegment.getSegmentAsNumbers()) {
segmentAsNumbersJson.add(asNumber);
}
pathSegmentJson.set("segmentAsNumbers", segmentAsNumbersJson);
pathSegmentsJson.add(pathSegmentJson);
}
result.set("pathSegments", pathSegmentsJson);
return result;
}
示例4: getPortStatistics
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
* Gets port statistics of all devices.
* @onos.rsModel StatisticsPorts
* @return 200 OK with JSON encoded array of port statistics
*/
@GET
@Path("ports")
@Produces(MediaType.APPLICATION_JSON)
public Response getPortStatistics() {
final DeviceService service = get(DeviceService.class);
final Iterable<Device> devices = service.getDevices();
final ObjectNode root = mapper().createObjectNode();
final ArrayNode rootArrayNode = root.putArray("statistics");
for (final Device device : devices) {
final ObjectNode deviceStatsNode = mapper().createObjectNode();
deviceStatsNode.put("device", device.id().toString());
final ArrayNode statisticsNode = deviceStatsNode.putArray("ports");
final Iterable<PortStatistics> portStatsEntries = service.getPortStatistics(device.id());
if (portStatsEntries != null) {
for (final PortStatistics entry : portStatsEntries) {
statisticsNode.add(codec(PortStatistics.class).encode(entry, this));
}
}
rootArrayNode.add(deviceStatsNode);
}
return ok(root).build();
}
示例5: process
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Override
public void process(long sid, ObjectNode payload) {
String id = string(payload, ID, ZERO_URI);
DeviceId deviceId = deviceId(id);
DeviceService service = get(DeviceService.class);
MastershipService ms = get(MastershipService.class);
Device device = service.getDevice(deviceId);
ObjectNode data = objectNode();
NodeId masterFor = ms.getMasterFor(deviceId);
data.put(ID, deviceId.toString());
data.put(NAME, deviceName(device));
data.put(TYPE, capitalizeFully(device.type().toString()));
data.put(TYPE_IID, getTypeIconId(device));
data.put(MFR, device.manufacturer());
data.put(HW, device.hwVersion());
data.put(SW, device.swVersion());
data.put(SERIAL, device.serialNumber());
data.put(CHASSIS_ID, device.chassisId().toString());
data.put(MASTER_ID, masterFor != null ? masterFor.toString() : NONE);
data.put(PROTOCOL, deviceProtocol(device));
ArrayNode ports = arrayNode();
List<Port> portList = new ArrayList<>(service.getPorts(deviceId));
Collections.sort(portList, (p1, p2) -> {
long delta = p1.number().toLong() - p2.number().toLong();
return delta == 0 ? 0 : (delta < 0 ? -1 : +1);
});
for (Port p : portList) {
ports.add(portData(p, deviceId));
}
data.set(PORTS, ports);
ObjectNode rootNode = objectNode();
rootNode.set(DETAILS, data);
sendMessage(DEV_DETAILS_RESP, 0, rootNode);
}
示例6: artifacts
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@CsapDoc ( notes = {
"Gets the artifacts configured in application definition",
"Optional: releasePackage - if not specified, all artifacts in all packages will be returned"
} , linkTests = {
"All Packages",
"changeMe package",
} , linkGetParams = {
"params=none", "releasePackage=changeMe"
} )
@GetMapping ( value={"/artifacts", "/mavenArtifacts"} )
public JsonNode artifacts ( String releasePackage ) {
if ( releasePackage == null ) {
releasePackage = application.getAllPackages().getReleasePackageName();
}
if ( application.getModel( releasePackage ) == null ) {
ObjectNode managerError = jacksonMapper.createObjectNode();
managerError.put( "error", "Unrecognized package name: " + releasePackage );
managerError.set( "available", packagesWithCluster() );
return managerError;
}
List<String> mavenIds = application.getModel( releasePackage )
.getServiceConfigStreamInCurrentLC()
.flatMap( serviceInstancesEntry -> serviceInstancesEntry.getValue().stream() )
.map( serviceInstance -> serviceInstance.getMavenId() )
.distinct()
.filter( version -> version.length() != 0 )
.collect( Collectors.toList() );
return jacksonMapper.convertValue( mavenIds, ArrayNode.class );
}
示例7: json
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private static ObjectNode json(LinkHighlight lh) {
ObjectNode n = objectNode()
.put(ID, lh.elementId())
.put(LABEL, lh.label())
.put(CSS, lh.cssClasses());
if (lh.subdued()) {
n.put(SUBDUE, true);
}
return n;
}
示例8: onAppliedConfiguration
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Override
public void onAppliedConfiguration(String configuration) {
try {
ObjectNode node = newNode();
node.put("appliedConfiguration", configuration);
MqttMessage msg = new MqttMessage(JsonTools.toString(node).getBytes(StandardCharsets.UTF_8));
tbClient.publish(DEVICE_ATTRIBUTES_TOPIC, msg).waitForCompletion();
} catch (Exception e) {
log.warn("Could not publish applied configuration", e);
}
}
示例9: getDatasetVersions
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
public static Result getDatasetVersions(Long datasetId, Integer dbId)
{
ObjectNode result = Json.newObject();
result.put("status", "ok");
result.set("versions", Json.toJson(DatasetsDAO.getDatasetVersions(datasetId, dbId)));
return ok(result);
}
示例10: matchMapValueOfFloatTypeWithFloatValue
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Test
public void matchMapValueOfFloatTypeWithFloatValue() throws JsonProcessingException, IOException {
Schema schema = SchemaBuilder.map().values().floatType();
ObjectMapper mapper = new ObjectMapper();
ObjectNode dataTable = mapper.createObjectNode();
JsonNode datum = dataTable.put("field1", Float.MAX_VALUE);
MatchType matchType = new JasvornoConverter(model, UndeclaredFieldBehaviour.NO_MATCH).matchMapValue(datum, schema);
assertThat(matchType, is(MatchType.FULL));
}
示例11: getDependViews
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
public static Result getDependViews(Long datasetId)
{
ObjectNode result = Json.newObject();
List<DatasetDependency> depends = new ArrayList<>();
DatasetsDAO.getDependencies(datasetId, depends);
result.put("status", "ok");
result.set("depends", Json.toJson(depends));
return ok(result);
}
示例12: getFlowOwners
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
public static Result getFlowOwners(String flowPath) {
String instance = request().getQueryString("instance");
ObjectNode resultJson = Json.newObject();
try {
List<Map<String, Object>> owners = FlowDao.getFlowOwner(flowPath, instance);
resultJson.put("return_code", 200);
resultJson.set("owners", Json.toJson(owners));
} catch (Exception e) {
e.printStackTrace();
resultJson.put("return_code", 404);
resultJson.put("error_message", e.getMessage());
}
return ok(resultJson);
}
示例13: processResultForMultiple
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Override
public void processResultForMultiple(SectionInfo info, SelectionSession session, ObjectNode link, IItem<?> item,
SelectedResource resource)
{
String attachmentUuid = resource.getAttachmentUuid();
if( !Check.isEmpty(attachmentUuid) )
{
ItemId itemId = getItemIdForResource(resource);
IAttachment attachment = itemResolver.getAttachmentForUuid(itemId, attachmentUuid,
resource.getKey().getExtensionType());
AttachmentType type = attachment.getAttachmentType();
if( type.equals(AttachmentType.CUSTOM) )
{
final CustomAttachment custom = (CustomAttachment) attachment;
if( custom.getType().equalsIgnoreCase(ScormUtils.ATTACHMENT_TYPE) )
{
link.put("uuid", itemId.getUuid());
link.put("version", itemId.getVersion());
link.put("filename", custom.getUrl());
ItemFile itemFile = itemFileService.getItemFile(itemId, null);
try( InputStream in = imsService.getImsManifestAsStream(itemFile, custom.getUrl(), true) )
{
link.put("scorm", IOUtils.toString(in));
}
catch( IOException ex )
{
LOGGER.error("Error reading manifest file", ex);
}
}
}
}
}
示例14: chatterToJSON
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
public JsonNode chatterToJSON() {
ObjectNode obj = mapper.createObjectNode();
obj.put("handle", handle);
obj.put("color",
String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()));
return obj;
}
示例15: playerToJson
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private JsonNode playerToJson(Document doc) {
if (doc == null) return null;
ObjectNode obj = mapper.createObjectNode();
obj.put("name", doc.getString("name"));
obj.put("tickets",doc.getInteger("tickets").toString());
obj.put("gold",doc.getInteger("gold").toString());
obj.put("games",doc.getInteger("games").toString());
return obj;
}