當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。