当前位置: 首页>>代码示例>>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;未经允许,请勿转载。