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


Java JsonNodeFactory.instance方法代碼示例

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


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

示例1: getUserFriendStatus

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
@ApiOperation(value = "Get the relationship status between users")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No user found") })
@PreAuthorize("hasRole('ROLE_USER')")
@GetMapping(value = "/{username}/status", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public
JsonNode getUserFriendStatus(
        @ApiParam(value = "The user's name", required = true)
        @PathVariable("username") final String username
) {
    log.info("Called with username {}", username);

    final String authId = this.authorizationService.getUserId();
    final String otherId = this.userSearchService.getUserByUsername(username).getId();

    if(authId.equals(otherId)) {
        throw new ResourceConflictException("Conflict IDs");
    }

    final JsonNodeFactory factory = JsonNodeFactory.instance;
    return factory
            .objectNode()
            .set("status", factory.textNode(this.userSearchService.getUserFriendStatus(authId, otherId).toString()));
}
 
開發者ID:JonkiPro,項目名稱:REST-Web-Services,代碼行數:25,代碼來源:UserRestController.java

示例2: makeInputValues

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
@Override
public Map<PortName, BrickValue> makeInputValues() {
    JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
    ObjectMapper mapper = new ObjectMapper();

    List<JsonNode> compareSessionJson = new ArrayList<>();
    JsonNode sessionNode = mapper.valueToTree(compareSession);
    BrickValue sessionBrickValue = new BrickValue(new BrickDataType("BrowserSessionRef"), sessionNode);
    compareSessionJson.add(mapper.valueToTree(sessionBrickValue));

    return ImmutableMap.of(
            new PortName("referenceSession"), new BrickValue(new BrickDataType("BrowserSessionRef"), jsonNodeFactory.textNode(referenceSession.getValueAsString())),
            new PortName("compareSession"), new BrickValue(new BrickDataType("BrowserSessionRef"), jsonNodeFactory.textNode(compareSession.getValueAsString())),
            new PortName("matchingType"), new BrickValue(new BrickDataType("String"), jsonNodeFactory.textNode("tag")),
            new PortName("enabledynamicelementsfilter"), new BrickValue(new BrickDataType("Boolean"), jsonNodeFactory.booleanNode(true))
    );
}
 
開發者ID:webmate-io,項目名稱:webmate-sdk-java,代碼行數:18,代碼來源:BrowserSessionRegressionJobInput.java

示例3: getComponentMeta

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
private ObjectNode getComponentMeta(ClassLoader classLoader) {
    Properties properties = loadComponentProperties(classLoader);
    if (properties == null) {
        return null;
    }
    String components = (String) properties.get("components");
    if (components == null) {
        return null;
    }
    String[] part = components.split("\\s");
    ObjectNode componentMeta = new ObjectNode(JsonNodeFactory.instance);
    for (String scheme : part) {
        // find the class name
        String javaType = extractComponentJavaType(classLoader, scheme);
        if (javaType == null) {
            continue;
        }
        String schemeMeta = loadComponentJSonSchema(classLoader, scheme, javaType);
        if (schemeMeta == null) {
            continue;
        }
        componentMeta.set(scheme, new TextNode(schemeMeta));
    }
    return componentMeta.size() > 0 ? componentMeta : null;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:26,代碼來源:ExtractConnectorDescriptorsMojo.java

示例4: write

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
@Override
public JsonNode write( final Object obj ) throws IOException{
  ArrayNode array = new ArrayNode( JsonNodeFactory.instance );
  if( ! ( obj instanceof List ) ){
    return array;
  }

  List<Object> listObj = (List)obj;
  for( Object childObj : listObj ){
    if( childObj instanceof List ){
      array.add( JacksonContainerToJsonObject.getFromList( (List<Object>)childObj ) );
    }
    else if( childObj instanceof Map ){
      array.add( JacksonContainerToJsonObject.getFromMap( (Map<Object,Object>)childObj ) );
    }
    else{
      array.add( ObjectToJsonNode.get( childObj ) );
    }
  }

  return array;
}
 
開發者ID:yahoojapan,項目名稱:dataplatform-schema-lib,代碼行數:23,代碼來源:JacksonArrayFormatter.java

示例5: writeParser

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
@Override
public JsonNode writeParser( final IParser parser ) throws IOException{
  ArrayNode array = new ArrayNode( JsonNodeFactory.instance );
  for( int i = 0 ; i < parser.size() ; i++ ){
    IParser childParser = parser.getParser( i );
    if( childParser.isMap() || childParser.isStruct() ){
      array.add( JacksonParserToJsonObject.getFromObjectParser( childParser ) );
    }
    else if( childParser.isArray() ){
      array.add( JacksonParserToJsonObject.getFromArrayParser( childParser ) );
    }
    else{
      array.add( PrimitiveObjectToJsonNode.get( parser.get( i ) ) );
    }
  }
  return array;
}
 
開發者ID:yahoojapan,項目名稱:dataplatform-schema-lib,代碼行數:18,代碼來源:JacksonArrayFormatter.java

示例6: write

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
@Override
public JsonNode write( final Object obj ) throws IOException{
  ObjectNode objectNode = new ObjectNode( JsonNodeFactory.instance );
  if( ! ( obj instanceof Map ) ){
    return objectNode;
  }

  Map<Object,Object> mapObj = (Map<Object,Object>)obj;
  for( Map.Entry<Object,Object> entry : mapObj.entrySet() ){
    String key = entry.getKey().toString();
    Object childObj = entry.getValue();
    if( childObj instanceof List ){
      objectNode.put( key , JacksonContainerToJsonObject.getFromList( (List<Object>)childObj ) );
    }
    else if( childObj instanceof Map ){
      objectNode.put( key , JacksonContainerToJsonObject.getFromMap( (Map<Object,Object>)childObj ) );
    }
    else{
      objectNode.put( key , ObjectToJsonNode.get( childObj ) );
    }
  }

  return objectNode;
}
 
開發者ID:yahoojapan,項目名稱:dataplatform-schema-lib,代碼行數:25,代碼來源:JacksonObjectFormatter.java

示例7: writeParser

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
@Override
public JsonNode writeParser( final IParser parser ) throws IOException{
  ObjectNode objectNode = new ObjectNode( JsonNodeFactory.instance );
  for( String key : parser.getAllKey() ){
    IParser childParser = parser.getParser( key );
    if( childParser.isMap() || childParser.isStruct() ){
      objectNode.put( key , JacksonParserToJsonObject.getFromObjectParser( childParser ) );
    }
    else if( childParser.isArray() ){
      objectNode.put( key , JacksonParserToJsonObject.getFromArrayParser( childParser ) );
    }
    else{
      objectNode.put( key , PrimitiveObjectToJsonNode.get( parser.get( key ) ) );
    }
  }
  return objectNode;
}
 
開發者ID:yahoojapan,項目名稱:dataplatform-schema-lib,代碼行數:18,代碼來源:JacksonObjectFormatter.java

示例8: getResult

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的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

示例9: generateJson

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
private String generateJson() {
    final JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
    ArrayNode filesListNode = nodeFactory.arrayNode();
    for (ManifestFile fileEntry : files) {
        ObjectNode fileNode = nodeFactory.objectNode();
        fileNode.set(JsonKeys.FILE_PATH, nodeFactory.textNode(fileEntry.name));
        fileNode.set(JsonKeys.FILE_HASH, nodeFactory.textNode(fileEntry.hash));
        filesListNode.add(fileNode);
    }

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

示例10: makeInputValues

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
@Override
public Map<PortName, BrickValue> makeInputValues() {
    JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
    ObjectMapper mapper = new ObjectMapper();

    List<JsonNode> compareSessionJson = new ArrayList<>();
    for (BrowserSessionId compareSession : compareSessions) {
        JsonNode sessionNode = mapper.valueToTree(compareSession);
        BrickValue sessionBrickValue = new BrickValue(new BrickDataType("BrowserSessionRef"), sessionNode);
        compareSessionJson.add(mapper.valueToTree(sessionBrickValue));
    }

    return ImmutableMap.of(
            new PortName("referenceSession"), new BrickValue(new BrickDataType("BrowserSessionRef"), jsonNodeFactory.textNode(referenceSession.toString())),
            new PortName("compareSessions"), new BrickValue(new BrickDataType("List[BrowserSessionRef]"), mapper.valueToTree(compareSessionJson)),
            new PortName("matchingType"), new BrickValue(new BrickDataType("String"), jsonNodeFactory.textNode("tag")),
            new PortName("enabledynamicelementsfilter"), new BrickValue(new BrickDataType("Boolean"), jsonNodeFactory.booleanNode(true))
    );
}
 
開發者ID:webmate-io,項目名稱:webmate-sdk-java,代碼行數:20,代碼來源:BrowserSessionCrossbrowserJobInput.java

示例11: createDataNode

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
private static JsonNode createDataNode(Map<String, Object> data) {
    JsonNodeFactory factory = JsonNodeFactory.instance;
    ObjectNode dataNode = factory.objectNode();

    Set<Map.Entry<String, Object>> dataSet = data.entrySet();
    for (Map.Entry<String, Object> entry : dataSet) {
        Object value = entry.getValue();
        if (value == null) {
            continue;
        }

        dataNode.set(entry.getKey(), factory.textNode(value.toString()));
    }

    return dataNode;
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:17,代碼來源:PluginResultHelper.java

示例12: addConnectorMeta

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
private void addConnectorMeta(ObjectNode root, ClassLoader classLoader) {
    ObjectNode node = new ObjectNode(JsonNodeFactory.instance);
    addOptionalNode(classLoader, node, "meta", "camel-connector.json");
    addOptionalSchemaAsString(classLoader, node, "schema", "camel-connector-schema.json");
    if (node.size() > 0) {
        root.set("connector", node);
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:9,代碼來源:ExtractConnectorDescriptorsMojo.java

示例13: shouldTryToLookupInJson

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的package包/類
@Test
public void shouldTryToLookupInJson() {
    final JsonNodeFactory factory = JsonNodeFactory.instance;
    final ObjectNode obj = factory.objectNode();
    obj.set("a", factory.arrayNode().add("b").add("c"));
    obj.set("x", factory.objectNode().set("y", factory.objectNode().put("z", "!")));

    assertThat(ErrorMap.tryLookingUp(obj, "a")).contains("b");
    assertThat(ErrorMap.tryLookingUp(obj, "a", "b")).isEmpty();
    assertThat(ErrorMap.tryLookingUp(obj, "x", "y")).contains("{\"z\":\"!\"}");
    assertThat(ErrorMap.tryLookingUp(obj, "x", "y", "z")).contains("!");
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:13,代碼來源:ErrorMapTest.java

示例14: generateJson

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的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

示例15: toString

import com.fasterxml.jackson.databind.node.JsonNodeFactory; //導入方法依賴的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


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