当前位置: 首页>>代码示例>>Java>>正文


Java JsonParser.nextTextValue方法代码示例

本文整理汇总了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);
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:25,代码来源:ContingencyDeserializer.java

示例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);
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:RestStringsModule.java

示例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);
}
 
开发者ID:claudiodegio,项目名称:dbsync,代码行数:24,代码来源:JsonDatabaseReader.java

示例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);
        }
    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:29,代码来源:TimeSeriesMetadata.java

示例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"));
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:13,代码来源:CredentialModule.java

示例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;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:43,代码来源:NetworkMetadataDeserializer.java

示例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;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:69,代码来源:LimitViolationDeserializer.java

示例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;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:48,代码来源:ContingencyElementDeserializer.java


注:本文中的com.fasterxml.jackson.core.JsonParser.nextTextValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。