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


Java JsonParser.readValueAs方法代碼示例

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


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

示例1: asMap

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public Map<String, Object> asMap() throws JWTDecodeException {
    if (!data.isObject()) {
        return null;
    }

    try {
        TypeReference<Map<String, Object>> mapType = new TypeReference<Map<String, Object>>() {
        };
        ObjectMapper thisMapper = getObjectMapper();
        JsonParser thisParser = thisMapper.treeAsTokens(data);
        return thisParser.readValueAs(mapType);
    } catch (IOException e) {
        throw new JWTDecodeException("Couldn't map the Claim value to Map", e);
    }
}
 
開發者ID:GJWT,項目名稱:javaOIDCMsg,代碼行數:17,代碼來源:JsonNodeClaim.java

示例2: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public PostContingencyResult deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException {
    Contingency contingency = null;
    LimitViolationsResult limitViolationsResult = null;

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        switch (parser.getCurrentName()) {
            case "contingency":
                parser.nextToken();
                contingency = parser.readValueAs(Contingency.class);
                break;

            case "limitViolationsResult":
                parser.nextToken();
                limitViolationsResult = parser.readValueAs(LimitViolationsResult.class);
                break;

            default:
                throw new AssertionError("Unexpected field: " + parser.getCurrentName());
        }
    }

    return new PostContingencyResult(contingency, limitViolationsResult);
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:25,代碼來源:PostContingencyResultDeserializer.java

示例3: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public ExtraValues deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException {
    float extraValue1 = Float.NaN;
    float extraValue2 = Float.NaN;

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        switch (parser.getCurrentName()) {
            case "extraValue1":
                parser.nextToken();
                extraValue1 = parser.readValueAs(Float.class);
                break;

            case "extraValue2":
                parser.nextToken();
                extraValue2 = parser.readValueAs(Float.class);
                break;

            default:
                throw new AssertionError("Unexpected field: " + parser.getCurrentName());
        }
    }

    return new ExtraValues(extraValue1, extraValue2);
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:25,代碼來源:ExtraValuesJson.java

示例4: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public Contingency deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
    String id = null;
    List<ContingencyElement> elements = Collections.emptyList();

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        switch (parser.getCurrentName()) {
            case "id":
                id = parser.nextTextValue();
                break;

            case "elements":
                parser.nextToken();
                elements = parser.readValueAs(new TypeReference<ArrayList<ContingencyElement>>() {
                });
                break;

            default:
                throw new AssertionError("Unexpected field: " + parser.getCurrentName());
        }
    }

    return new ContingencyImpl(id, elements);
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:25,代碼來源:ContingencyDeserializer.java

示例5: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public LoadFlowResult deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
    Boolean isOK = null;
    Map<String, String> metrics = null;
    String log = null;

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        switch (parser.getCurrentName()) {
            case "version":
                parser.nextToken(); // skip
                break;

            case "isOK":
                parser.nextToken();
                isOK = parser.readValueAs(Boolean.class);
                break;

            case "metrics":
                parser.nextToken();
                metrics = parser.readValueAs(HashMap.class);
                break;

            default:
                throw new AssertionError("Unexpected field: " + parser.getCurrentName());
        }
    }

    return new LoadFlowResultImpl(isOK, metrics, log);
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:30,代碼來源:LoadFlowResultDeserializer.java

示例6: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public LimitViolationsResult deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException {
    boolean comutationOk = false;
    List<LimitViolation> limitViolations = Collections.emptyList();
    List<String> actionsTaken = Collections.emptyList();

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        switch (parser.getCurrentName()) {
            case "computationOk":
                comutationOk = parser.nextBooleanValue();
                break;

            case "limitViolations":
                parser.nextToken();
                limitViolations = parser.readValueAs(new TypeReference<ArrayList<LimitViolation>>() {
                });
                break;

            case "actionsTaken":
                parser.nextToken();
                actionsTaken = parser.readValueAs(new TypeReference<ArrayList<String>>() {
                });
                break;

            default:
                throw new AssertionError("Unexpected field: " + parser.getCurrentName());
        }
    }

    return new LimitViolationsResult(comutationOk, limitViolations, actionsTaken);
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:32,代碼來源:LimitViolationResultDeserializer.java

示例7: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public PreContingency deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException {
    float value = Float.NaN;

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        if (parser.getCurrentName().equals("value")) {
            parser.nextToken();
            value = parser.readValueAs(Float.class);
        } else {
            throw new PowsyblException("Unexpected field: " + parser.getCurrentName());
        }
    }

    return new PreContingency(value);
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:16,代碼來源:PreContingencyJson.java

示例8: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public JsonRpcResponse deserialize(JsonParser parser, DeserializationContext context)	
		throws IOException, JsonProcessingException {
	RawJsonRpcResponse rawRpcResponse = parser.readValueAs(RawJsonRpcResponse.class);

	return rawRpcResponse.toJsonRpcResponse();
}
 
開發者ID:Roxas240,項目名稱:CryptoPayAPI,代碼行數:8,代碼來源:JsonRpcResponseDeserializer.java

示例9: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public Nullable<Object> deserialize(JsonParser jp, DeserializationContext context) throws IOException {
	JsonToken currentToken = jp.getCurrentToken();
	if (currentToken == JsonToken.START_ARRAY) {
		ResourceIdentifier[] resources = jp.readValueAs(ResourceIdentifier[].class);
		return Nullable.of((Object) Arrays.asList(resources));
	}
	else if (currentToken == JsonToken.VALUE_NULL) {
		return Nullable.of(null);
	}
	else {
		PreconditionUtil.assertEquals("parsing failed", currentToken, JsonToken.START_OBJECT);
		return Nullable.of((Object) jp.readValueAs(ResourceIdentifier.class));
	}
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:16,代碼來源:RelationshipDataDeserializer.java

示例10: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public IConnectionXInfoDTO deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    String type = (String) ctxt.getAttribute("xinfo_key");
    try {
        return (IConnectionXInfoDTO) jp.readValueAs(this.segmentAdapter.getConnectionXInfoAdapterRegistry().getObjectForType(type).getDtoClass());
    } catch (XInfoNotSupportedException e) {
        throw new XInfoDeserializationException("XInfo is not supported",e);
    }
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:10,代碼來源:ConnectionXInfoDeserializer.java

示例11: processSegment

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
protected T processSegment(JsonParser jp,
		ISegmentAdapter<IBaseSegmentDTO, T> adapter) throws IOException {
	if(jp.currentToken() != JsonToken.START_OBJECT) {
		jp.nextValue();
	}
	IBaseSegmentDTO dto = jp.readValueAs(adapter.getDtoClass());
	return adapter.adaptReverse(dto);
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:9,代碼來源:GenericJacksonSegmentInputFormat.java

示例12: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public ISegmentXInfoDTO deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    //String type = jp.getCurrentName();
    String type = (String) ctxt.getAttribute("xinfo_key");
    try {
        return (ISegmentXInfoDTO) jp.readValueAs(this.segmentAdapter.getSegmentXInfoAdapterRegistry().getObjectForType(type).getDtoClass());
    } catch (XInfoNotSupportedException e) {
        throw new XInfoDeserializationException("XInfo is not supported",e);
    }
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:11,代碼來源:SegmentXInfoDeserializer.java

示例13: processSegment

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
protected IBaseSegmentDTO processSegment(JsonParser jp,
		ISegmentAdapter<IBaseSegmentDTO, T> adapter) throws IOException {
	if(jp.currentToken() != JsonToken.START_OBJECT) {
		jp.nextValue();
	}
	IBaseSegmentDTO dto = jp.readValueAs(adapter.getDtoClass());
	return dto;
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:9,代碼來源:JacksonBaseSegmentDTOInputFormat.java

示例14: testSerialize

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

示例15: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public SecurityAnalysisResult deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
    NetworkMetadata networkMetadata = null;
    LimitViolationsResult preContingencyResult = null;
    List<PostContingencyResult> postContingencyResults = Collections.emptyList();
    List<Extension<SecurityAnalysisResult>> extensions = Collections.emptyList();

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        switch (parser.getCurrentName()) {
            case "version":
                parser.nextToken(); // skip
                break;

            case "network":
                parser.nextToken();
                networkMetadata = parser.readValueAs(NetworkMetadata.class);
                break;

            case "preContingencyResult":
                parser.nextToken();
                preContingencyResult = parser.readValueAs(LimitViolationsResult.class);
                break;

            case "postContingencyResults":
                parser.nextToken();
                postContingencyResults = parser.readValueAs(new TypeReference<ArrayList<PostContingencyResult>>() {
                });
                break;

            case "extensions":
                parser.nextToken();
                extensions = JsonUtil.readExtensions(parser, ctx);
                break;

            default:
                throw new AssertionError("Unexpected field: " + parser.getCurrentName());
        }
    }

    SecurityAnalysisResult result = new SecurityAnalysisResult(preContingencyResult, postContingencyResults);
    result.setNetworkMetadata(networkMetadata);
    ExtensionSupplier.addExtensions(result, extensions);

    return result;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:46,代碼來源:SecurityAnalysisResultDeserializer.java


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