本文整理匯總了Java中com.fasterxml.jackson.core.JsonParser.nextTextValue方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParser.nextTextValue方法的具體用法?Java JsonParser.nextTextValue怎麽用?Java JsonParser.nextTextValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.nextTextValue方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public I18NStrings deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
JsonProcessingException
{
Map<String, LanguageString> strings = Maps.newHashMap();
JsonToken currentToken = jp.getCurrentToken();
if( currentToken != JsonToken.START_OBJECT )
{
throw new JsonParseException("Must be an object", jp.getCurrentLocation());
}
while( jp.nextToken() == JsonToken.FIELD_NAME )
{
String textValue = jp.nextTextValue();
LanguageBundle tempBundle = LangUtils.createTempLangugageBundle(null, textValue);
LanguageString tempLangString = LangUtils.createLanguageString(tempBundle, CurrentLocale.getLocale(),
textValue);
strings.put(jp.getCurrentName(), tempLangString);
}
return new SimpleI18NStrings(strings);
}
示例3: readTable
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
private void readTable(JsonParser jp) throws IOException {
JsonToken token;
String tableName = "";
int recordCount = 0;
while((token = jp.nextToken()) != JsonToken.END_OBJECT) {
if (token == JsonToken.FIELD_NAME) {
if ("name".equals(jp.getCurrentName())) {
tableName = jp.nextTextValue();
} else if ("records".equals(jp.getCurrentName())){
// Ciclo la lista dei records
while((token = jp.nextToken()) != JsonToken.END_ARRAY) {
readRecord(jp);
recordCount++;
}
}
}
}
System.out.println("\tTable: " + tableName + " records:" + recordCount);
numeriche.put(tableName, recordCount);
}
示例4: parseFieldName
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
static void parseFieldName(JsonParser parser, JsonParsingContext context) throws IOException {
String fieldName = parser.getCurrentName();
if (context.insideTags) {
context.tags.put(fieldName, parser.nextTextValue());
} else {
switch (fieldName) {
case "metadata":
break;
case "name":
context.name = parser.nextTextValue();
break;
case "dataType":
context.dataType = TimeSeriesDataType.valueOf(parser.nextTextValue());
break;
case "tags":
context.insideTags = true;
break;
case RegularTimeSeriesIndex.TYPE:
context.index = RegularTimeSeriesIndex.parseJson(parser);
break;
case InfiniteTimeSeriesIndex.TYPE:
context.index = InfiniteTimeSeriesIndex.parseJson(parser);
break;
default:
throw new IllegalStateException("Unexpected field name " + fieldName);
}
}
}
示例5: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public OAuthToken deserialize(final JsonParser p, final DeserializationContext ctxt)
throws IOException, JsonProcessingException {
final Map<String, String> values = new HashMap<>();
String fieldName;
while ((fieldName = p.nextFieldName()) != null) {
final String nextValue = p.nextTextValue();
values.put(fieldName, nextValue);
}
return new OAuthToken(values.get("value"), values.get("secret"));
}
示例6: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public NetworkMetadata deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException {
String id = null;
String sourceFormat = null;
DateTime caseDate = null;
int forecastDistance = 0;
List<Extension<NetworkMetadata>> extensions = Collections.emptyList();
while (parser.nextToken() != JsonToken.END_OBJECT) {
switch (parser.getCurrentName()) {
case "id":
id = parser.nextTextValue();
break;
case "sourceFormat":
sourceFormat = parser.nextTextValue();
break;
case "caseDate":
caseDate = DateTime.parse(parser.nextTextValue());
break;
case "forecastDistance":
forecastDistance = parser.nextIntValue(0);
break;
case "extensions":
parser.nextToken();
extensions = JsonUtil.readExtensions(parser, deserializationContext);
break;
default:
throw new PowsyblException("Unexpected field: " + parser.getCurrentName());
}
}
NetworkMetadata metadata = new NetworkMetadata(id, sourceFormat, caseDate, forecastDistance);
ExtensionSupplier.addExtensions(metadata, extensions);
return metadata;
}
示例7: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public LimitViolation deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException {
String subjectId = null;
LimitViolationType limitType = null;
String limitName = null;
int acceptableDuration = Integer.MAX_VALUE;
float limit = Float.NaN;
float limitReduction = Float.NaN;
float value = Float.NaN;
Branch.Side side = null;
List<Extension<LimitViolation>> extensions = Collections.emptyList();
while (parser.nextToken() != JsonToken.END_OBJECT) {
switch (parser.getCurrentName()) {
case "subjectId":
subjectId = parser.nextTextValue();
break;
case "limitType":
parser.nextToken();
limitType = parser.readValueAs(LimitViolationType.class);
break;
case "limitName":
limitName = parser.nextTextValue();
break;
case "acceptableDuration":
parser.nextToken();
acceptableDuration = parser.readValueAs(Integer.class);
break;
case "limit":
parser.nextToken();
limit = parser.readValueAs(Float.class);
break;
case "limitReduction":
parser.nextToken();
limitReduction = parser.readValueAs(Float.class);
break;
case "value":
parser.nextToken();
value = parser.readValueAs(Float.class);
break;
case "side":
parser.nextToken();
side = parser.readValueAs(Branch.Side.class);
break;
case "extensions":
parser.nextToken();
extensions = JsonUtil.readExtensions(parser, deserializationContext);
break;
default:
throw new AssertionError("Unexpected field: " + parser.getCurrentName());
}
}
LimitViolation violation = new LimitViolation(subjectId, limitType, limitName, acceptableDuration, limit, limitReduction, value, side);
ExtensionSupplier.addExtensions(violation, extensions);
return violation;
}
示例8: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public ContingencyElement deserialize(JsonParser parser, DeserializationContext ctx) throws IOException {
String id = null;
String voltageLevelId = null;
ContingencyElementType type = null;
while (parser.nextToken() != JsonToken.END_OBJECT) {
switch (parser.getCurrentName()) {
case "id":
id = parser.nextTextValue();
break;
case "voltageLevelId":
voltageLevelId = parser.nextTextValue();
break;
case "type":
parser.nextToken();
type = parser.readValueAs(ContingencyElementType.class);
break;
default:
throw new AssertionError("Unexpected field: " + parser.getCurrentName());
}
}
if (type != null) {
switch (type) {
case BRANCH:
return new BranchContingency(id, voltageLevelId);
case GENERATOR:
return new GeneratorContingency(id);
case HVDC_LINE:
return new HvdcLineContingency(id, voltageLevelId);
case BUSBAR_SECTION:
return new BusbarSectionContingency(id);
default:
throw new AssertionError("Unexpected ContingencyElementType value: " + type);
}
}
return null;
}