当前位置: 首页>>代码示例>>Java>>正文


Java MappingJsonFactory类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.MappingJsonFactory的典型用法代码示例。如果您正苦于以下问题:Java MappingJsonFactory类的具体用法?Java MappingJsonFactory怎么用?Java MappingJsonFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MappingJsonFactory类属于com.fasterxml.jackson.databind包,在下文中一共展示了MappingJsonFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WampClient

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
public WampClient(DataFormat dataFormat) {
	this.isBinary = dataFormat != DataFormat.JSON;
	this.result = new CompletableFutureWebSocketHandler();
	this.headers = new WebSocketHttpHeaders();

	switch (dataFormat) {
	case CBOR:
		this.jsonFactory = new ObjectMapper(new CBORFactory()).getFactory();
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.CBOR_PROTOCOL);
		break;
	case MSGPACK:
		this.jsonFactory = new ObjectMapper(new MessagePackFactory()).getFactory();
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.MSGPACK_PROTOCOL);
		break;
	case JSON:
		this.jsonFactory = new MappingJsonFactory(new ObjectMapper());
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.JSON_PROTOCOL);
		break;
	case SMILE:
		this.jsonFactory = new ObjectMapper(new SmileFactory()).getFactory();
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.SMILE_PROTOCOL);
		break;
	default:
		this.jsonFactory = null;
	}

}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:28,代码来源:WampClient.java

示例2: GenericJacksonWayGraphOutputFormat

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
public GenericJacksonWayGraphOutputFormat(ISegmentOutputFormat<T> segmentOutputFormat, 
		IAdapter<IGraphVersionMetadataDTO, IWayGraphVersionMetadata> adapter,
		OutputStream stream, 
		JsonGenerator generator)
{
	this.segmentOutputFormat = segmentOutputFormat;
	this.adapter = adapter;
	if (generator == null) {
		try {
			this.generator = new MappingJsonFactory().createGenerator(stream, JsonEncoding.UTF8);
			this.generator.useDefaultPrettyPrinter();
		} catch (IOException e) {
			log.error("error creating jackson json factory", e);
		}
	} else {
		this.generator = generator;
	}
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:19,代码来源:GenericJacksonWayGraphOutputFormat.java

示例3: GenericJacksonSegmentOutputFormat

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
public GenericJacksonSegmentOutputFormat(ISegmentAdapterRegistry<? extends IBaseSegmentDTO, T> adapterRegistry,
		OutputStream stream, JsonGenerator generator, int flushBatchCount)
{
	this.adapterRegistry = adapterRegistry;
	if (generator == null) {
		try {
			this.generator = new MappingJsonFactory().createGenerator(new BufferedOutputStream(stream), JsonEncoding.UTF8);
			this.generator.useDefaultPrettyPrinter();
		} catch (IOException e) {
			log.error("error creating jackson json factory", e);
		}
	}
	if (flushBatchCount > 0 ) {
		this.flushBatchCount = flushBatchCount;
	} else {
		log.warn("flushBatchCount ignored, can not be negative or 0");
	}
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:19,代码来源:GenericJacksonSegmentOutputFormat.java

示例4: convert

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
@Override
public String convert(final List<ComplexNestedType> object) {
    try {
        StringWriter writer = new StringWriter();
        JsonFactory jsonFactory = new MappingJsonFactory();
        JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(writer);
        jsonGenerator.writeObject(object);
        return writer.toString();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:13,代码来源:ComplexTypeIntegrationTest.java

示例5: jsonExtractSubnetMask

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
	String subnet_mask = "";
	MappingJsonFactory f = new MappingJsonFactory();
	JsonParser jp;

	try {
		jp = f.createParser(fmJson);
	} catch (JsonParseException e) {
		throw new IOException(e);
	}

	jp.nextToken();
	if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
		throw new IOException("Expected START_OBJECT");
	}

	while (jp.nextToken() != JsonToken.END_OBJECT) {
		if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw new IOException("Expected FIELD_NAME");
		}

		String n = jp.getCurrentName();
		jp.nextToken();
		if (jp.getText().equals(""))
			continue;

		if (n == "subnet-mask") {
			subnet_mask = jp.getText();
			break;
		}
	}

	return subnet_mask;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:41,代码来源:FirewallSubnetMaskResource.java

示例6: deserialize

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
@Override
public Data<Resource> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException {
    JsonNode node = jsonParser.getCodec().readTree(jsonParser);
    ObjectMapper mapper = new MappingJsonFactory().getCodec();
    if (node.isArray()) {
        List<Resource> resources = new ArrayList<>();
        for (JsonNode n : node) {
            Resource r = mapper.convertValue(n, Resource.class);
            resources.add(r);
        }
        return new Data<>(resources);
    }
    Resource resource = mapper.convertValue(node, Resource.class);
    return new Data<>(resource);
}
 
开发者ID:yahoo,项目名称:elide,代码行数:17,代码来源:DataDeserializer.java

示例7: wampWebSocketHandlerMapping

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
@Bean
public HandlerMapping wampWebSocketHandlerMapping() {
	WebSocketHandler handler = subProtocolWebSocketHandler();
	handler = decorateWebSocketHandler(handler);

	WebMvcWampEndpointRegistry registry = new WebMvcWampEndpointRegistry(handler,
			getTransportRegistration(), messageBrokerSockJsTaskScheduler(),
			new MappingJsonFactory(lookupObjectMapper()));

	List<HandshakeInterceptor> handshakeInterceptors = new ArrayList<>();
	addHandshakeInterceptors(handshakeInterceptors);
	registry.addHandshakeInterceptors(handshakeInterceptors);

	registerWampEndpoints(registry);

	return registry.getHandlerMapping();
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:18,代码来源:DefaultWampConfiguration.java

示例8: CompletableFutureWebSocketHandler

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
public CompletableFutureWebSocketHandler(int expectedNoOfResults) {
	this.jsonFactory = new MappingJsonFactory(new ObjectMapper());
	this.msgpackFactory = new ObjectMapper(new MessagePackFactory()).getFactory();
	this.cborFactory = new ObjectMapper(new CBORFactory()).getFactory();
	this.smileFactory = new ObjectMapper(new SmileFactory()).getFactory();
	this.timeout = getTimeoutValue();
	this.welcomeMessageFuture = new CompletableFuture<>();
	this.reset(expectedNoOfResults);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:10,代码来源:CompletableFutureWebSocketHandler.java

示例9: testSerialize

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
@Test
public void testSerialize() throws IOException {
    String test = "[{\"name\":\"HalloHallo\",\"segmentId\":12345}]";
    InputStream stream = new ByteArrayInputStream( test.getBytes() );
    JsonFactory factory = new MappingJsonFactory();
    JsonParser parser = factory.createParser(stream);
    JsonToken token = parser.nextToken();
    if (token == JsonToken.START_ARRAY) {
        do {
            parser.nextToken();
            DefaultSegmentXInfoDTO segmentXInfoDTO = parser.readValueAs(DefaultSegmentXInfoDTO.class);
        } while (token == JsonToken.END_ARRAY);
    }
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:15,代码来源:TestSerializeContainer.java

示例10: unconvert

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
@Override
public List<ComplexNestedType> unconvert(String obj) {
    try {
        JsonFactory jsonFactory = new MappingJsonFactory();
        JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(obj));
        return jsonParser.readValueAs(new TypeReference<List<ComplexNestedType>>() {
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:12,代码来源:ComplexTypeIntegrationTest.java

示例11: jsonToHostDefinition

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    
    try {
        jp = f.createParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }
    
    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }
    
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }
        
        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }
    
    jp.close();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:39,代码来源:HostResource.java

示例12: getEntryNameFromJson

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
	MappingJsonFactory f = new MappingJsonFactory();
	JsonParser jp;

	try {
		jp = f.createParser(fmJson);
	} catch (JsonParseException e) {
		throw new IOException(e);
	}

	jp.nextToken();
	if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
		throw new IOException("Expected START_OBJECT");
	}

	while (jp.nextToken() != JsonToken.END_OBJECT) {
		if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw new IOException("Expected FIELD_NAME");
		}

		String n = jp.getCurrentName();
		jp.nextToken();
		if (jp.getText().equals("")) 
			continue;

		if (n == StaticFlowEntryPusher.COLUMN_NAME)
			return jp.getText();
	}
	return null;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:37,代码来源:StaticFlowEntries.java

示例13: jsonToHostDefinition

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    
    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }
    
    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }
    
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }
        
        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }
    
    jp.close();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:39,代码来源:HostResource.java

示例14: getEntryNameFromJson

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
	MappingJsonFactory f = new MappingJsonFactory();
	JsonParser jp;

	try {
		jp = f.createJsonParser(fmJson);
	} catch (JsonParseException e) {
		throw new IOException(e);
	}

	jp.nextToken();
	if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
		throw new IOException("Expected START_OBJECT");
	}

	while (jp.nextToken() != JsonToken.END_OBJECT) {
		if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw new IOException("Expected FIELD_NAME");
		}

		String n = jp.getCurrentName();
		jp.nextToken();
		if (jp.getText().equals("")) 
			continue;

		if (n == StaticFlowEntryPusher.COLUMN_NAME)
			return jp.getText();
	}
	return null;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:37,代码来源:StaticFlowEntries.java

示例15: jsonExtractSubnetMask

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入依赖的package包/类
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
	String subnet_mask = "";
	MappingJsonFactory f = new MappingJsonFactory();
	JsonParser jp;

	try {
		jp = f.createJsonParser(fmJson);
	} catch (JsonParseException e) {
		throw new IOException(e);
	}

	jp.nextToken();
	if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
		throw new IOException("Expected START_OBJECT");
	}

	while (jp.nextToken() != JsonToken.END_OBJECT) {
		if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw new IOException("Expected FIELD_NAME");
		}

		String n = jp.getCurrentName();
		jp.nextToken();
		if (jp.getText().equals(""))
			continue;

		if (n == "subnet-mask") {
			subnet_mask = jp.getText();
			break;
		}
	}

	return subnet_mask;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:41,代码来源:FirewallSubnetMaskResource.java


注:本文中的com.fasterxml.jackson.databind.MappingJsonFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。