本文整理汇总了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()));
}
示例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))
);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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();
}
示例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))
);
}
示例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;
}
示例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);
}
}
示例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("!");
}
示例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();
}
示例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();
}