本文整理匯總了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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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));
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}