當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。