當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectNode.toString方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.node.ObjectNode.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectNode.toString方法的具體用法?Java ObjectNode.toString怎麽用?Java ObjectNode.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.node.ObjectNode的用法示例。


在下文中一共展示了ObjectNode.toString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getJsonBufferPadded

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private ByteBuffer getJsonBufferPadded(ObjectNode jsonValue, int byteOffset) {
		if (jsonValue == null || jsonValue.size() == 0) {
			return ByteBuffer.allocate(0);
		}
		String jsonStr = jsonValue.toString();
		
		int boundary = 8;
		int byteLength = jsonStr.getBytes().length;
		int remainder = (byteOffset + byteLength) % boundary;
		int padding = (remainder == 0) ? 0 : boundary - remainder;
		
		ByteBuffer result = ByteBuffer.allocate(byteLength + padding);
		result.put(jsonStr.getBytes());
		for (int i = 0; i < padding; ++i) result.put((byte) 0x20);
//		String s = new String(result.array());
		return result;
	}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:18,代碼來源:GlbToB3dmConvertor.java

示例2: jsonDashboard

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Returns the dashboard page data as JSON.
 *
 * @return dashboard page JSON data
 */
public synchronized String jsonDashboard() {
    log.info("jsonDashboard()");

    if (email == null) {
        return jsonLogout();
    }

    BundleDescriptor bundleDescriptor = currentBundle.descriptor();
    ObjectNode root = objectNode();
    root.put(BUNDLE_NAME, bundleDescriptor.displayName());
    root.put(BUNDLE_DESC, bundleDescriptor.description());
    root.set(USERS, userJsonArray());
    addSubId(root);
    return root.toString();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:21,代碼來源:CordModelCache.java

示例3: getResult

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private static PluginResult getResult(String action, JsonNode data, JsonNode error) {
    JsonNodeFactory factory = JsonNodeFactory.instance;

    ObjectNode resultObject = factory.objectNode();
    if (action != null) {
        resultObject.set(JsParams.General.ACTION, factory.textNode(action));
    }

    if (data != null) {
        resultObject.set(JsParams.General.DATA, data);
    }

    if (error != null) {
        resultObject.set(JsParams.General.ERROR, error);
    }

    return new PluginResult(PluginResult.Status.OK, resultObject.toString());
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:19,代碼來源:PluginResultHelper.java

示例4: jsonFormat

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private String jsonFormat ( ObjectNode json ) {
	String result = json.toString();
	try {
		result = jacksonMapper.writerWithDefaultPrettyPrinter().writeValueAsString( json );
	} catch (JsonProcessingException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	return result;
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:12,代碼來源:ServiceOsManager.java

示例5: basicBundleJson

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Test
public void basicBundleJson() {
    ObjectNode node = BundleFactory.toObjectNode(cache.getCurrentBundle());
    String json = node.toString();
    System.out.println(json);
    assertTrue("bad basic json", sameJson(BASIC_BUNDLE_JSON, json));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:8,代碼來源:CoreModelCacheTest.java

示例6: xml2json

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@RequestMapping("xml2json")
public String xml2json(
        @RequestParam("processDefinitionId") String processDefinitionId)
        throws Exception {
    RepositoryService repositoryService = processEngine
            .getRepositoryService();

    ProcessDefinition processDefinition = repositoryService
            .getProcessDefinition(processDefinitionId);

    Model model = repositoryService.newModel();
    model.setName(processDefinition.getName());
    model.setDeploymentId(processDefinition.getDeploymentId());
    repositoryService.saveModel(model);

    BpmnModel bpmnModel = repositoryService
            .getBpmnModel(processDefinitionId);
    ObjectNode objectNode = new BpmnJsonConverter()
            .convertToJson(bpmnModel);

    String json = objectNode.toString();

    repositoryService.addModelEditorSource(model.getId(),
            json.getBytes("utf-8"));

    return "redirect:/modeler/modeler-list.do";
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:28,代碼來源:ModelerController.java

示例7: test_inline_template

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Test
public void test_inline_template() throws Exception {

    // Create the log event.
    SimpleMessage message = new SimpleMessage("Hello, World");
    String timestamp = "2017-09-28T17:13:29.098+02:00";
    long timeMillis = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX").parse(timestamp).getTime();
    LogEvent logEvent = Log4jLogEvent
            .newBuilder()
            .setLoggerName(LogstashLayoutTest.class.getSimpleName())
            .setLevel(Level.INFO)
            .setMessage(message)
            .setTimeMillis(timeMillis)
            .build();

    // Create the template.
    ObjectNode templateRootNode = JSON_NODE_FACTORY.objectNode();
    templateRootNode.put("@timestamp", "${json:timestamp}");
    String staticFieldName = "staticFieldName";
    String staticFieldValue = "staticFieldValue";
    templateRootNode.put(staticFieldName, staticFieldValue);
    String template = templateRootNode.toString();

    // Create the layout.
    BuiltConfiguration configuration = ConfigurationBuilderFactory.newConfigurationBuilder().build();
    String timeZoneId = TimeZone.getTimeZone("Europe/Amsterdam").getID();
    LogstashLayout layout = LogstashLayout
            .newBuilder()
            .setConfiguration(configuration)
            .setTemplate(template)
            .setTimeZoneId(timeZoneId)
            .build();

    // Check the serialized event.
    String serializedLogEvent = layout.toSerializable(logEvent);
    JsonNode rootNode = OBJECT_MAPPER.readTree(serializedLogEvent);
    assertThat(point(rootNode, "@timestamp").asText()).isEqualTo(timestamp);
    assertThat(point(rootNode, staticFieldName).asText()).isEqualTo(staticFieldValue);

}
 
開發者ID:vy,項目名稱:log4j2-logstash-layout,代碼行數:41,代碼來源:LogstashLayoutTest.java

示例8: test_property_injection

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Test
public void test_property_injection() throws Exception {

    // Create the log event.
    SimpleMessage message = new SimpleMessage("Hello, World");
    LogEvent logEvent = Log4jLogEvent
            .newBuilder()
            .setLoggerName(LogstashLayoutTest.class.getSimpleName())
            .setLevel(Level.INFO)
            .setMessage(message)
            .build();

    // Create the template with property.
    ObjectNode templateRootNode = JSON_NODE_FACTORY.objectNode();
    String propertyName = "propertyName";
    templateRootNode.put(propertyName, "${" + propertyName + "}");
    String template = templateRootNode.toString();

    // Create the layout with property.
    String propertyValue = "propertyValue";
    Configuration config = ConfigurationBuilderFactory
            .newConfigurationBuilder()
            .addProperty(propertyName, propertyValue)
            .build();
    LogstashLayout layout = LogstashLayout
            .newBuilder()
            .setConfiguration(config)
            .setTemplate(template)
            .build();

    // Check the serialized event.
    String serializedLogEvent = layout.toSerializable(logEvent);
    JsonNode rootNode = OBJECT_MAPPER.readTree(serializedLogEvent);
    assertThat(point(rootNode, propertyName).asText()).isEqualTo(propertyValue);

}
 
開發者ID:vy,項目名稱:log4j2-logstash-layout,代碼行數:37,代碼來源:LogstashLayoutTest.java

示例9: toString

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Convert object into JSON string
 *
 * @return JSON string
 */
@Override
public String toString() {
    JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
    ObjectNode object = nodeFactory.objectNode();
    object.set(APPLICATION_BUILD_VERSION, nodeFactory.numberNode(appBuildVersion));
    object.set(WWW_FOLDER_INSTALLED_FLAG, nodeFactory.booleanNode(wwwFolderInstalled));
    object.set(CURRENT_RELEASE_VERSION_NAME, nodeFactory.textNode(currentReleaseVersionName));
    object.set(PREVIOUS_RELEASE_VERSION_NAME, nodeFactory.textNode(previousReleaseVersionName));
    object.set(READY_FOR_INSTALLATION_RELEASE_VERSION_NAME, nodeFactory.textNode(readyForInstallationReleaseVersionName));

    return object.toString();
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:18,代碼來源:PluginInternalPreferences.java

示例10: jsonUsers

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Returns the users page data as JSON.
 *
 * @return users page JSON data
 */
public synchronized String jsonUsers() {
    log.info("jsonUsers()");

    if (email == null) {
        return jsonLogout();
    }

    ObjectNode root = objectNode();
    root.set(USERS, userJsonArray());
    addSubId(root);
    return root.toString();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:CordModelCache.java

示例11: generateJson

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private String generateJson() {
    JsonNodeFactory nodeFactory = JsonNodeFactory.instance;

    ObjectNode json = (ObjectNode) contentConfig.toJson();
    json.set(JsonKeys.STORE_PACKAGE_IDENTIFIER, nodeFactory.textNode(storeIdentifier));

    return json.toString();
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:9,代碼來源:ApplicationConfig.java

示例12: jsonBundle

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Returns the bundle page data as JSON.
 *
 * @return bundle page JSON data
 */
public synchronized String jsonBundle() {
    log.info("jsonBundle()");

    if (email == null) {
        return jsonLogout();
    }

    ObjectNode root = BundleFactory.toObjectNode(currentBundle);
    addSubId(root);
    return root.toString();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:17,代碼來源:CordModelCache.java

示例13: familyBundleJson

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@Test
public void familyBundleJson() {
    cache.setCurrentBundle("family");
    ObjectNode node = BundleFactory.toObjectNode(cache.getCurrentBundle());
    String json = node.toString();
    System.out.println(json);
    assertTrue("bad family json", sameJson(FAMILY_BUNDLE_JSON, json));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:9,代碼來源:CoreModelCacheTest.java

示例14: userPreferences

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private InputStream userPreferences(String userName) {
    UiPreferencesService service = get(UiPreferencesService.class);
    ObjectNode prefs = mapper().createObjectNode();
    service.getPreferences(userName).forEach(prefs::set);
    String string = "var userPrefs = " + prefs.toString() + ";\n";
    return new ByteArrayInputStream(string.getBytes());
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:8,代碼來源:MainIndexResource.java

示例15: allAsString

import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
public static String allAsString() {
	ObjectNode result = OBJECT_MAPPER.createObjectNode();
	result.put("includeAllFields", true);
	
	return result.toString();
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:7,代碼來源:DefaultQueries.java


注:本文中的com.fasterxml.jackson.databind.node.ObjectNode.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。