當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonParser.getCurrentName方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.core.JsonParser.getCurrentName方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParser.getCurrentName方法的具體用法?Java JsonParser.getCurrentName怎麽用?Java JsonParser.getCurrentName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.core.JsonParser的用法示例。


在下文中一共展示了JsonParser.getCurrentName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public ExternalModel parse(JsonParser jsonParser) throws IOException {
  ExternalModel instance = new ExternalModel();
  if (jsonParser.getCurrentToken() == null) {
    jsonParser.nextToken();
  }
  if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jsonParser.skipChildren();
    return null;
  }
  while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
    String fieldName = jsonParser.getCurrentName();
    jsonParser.nextToken();
    parseField(instance, fieldName, jsonParser);
    jsonParser.skipChildren();
  }
  return instance;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:ExternalModel$$JsonObjectMapper.java

示例2: parseFieldName

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
static void parseFieldName(JsonParser parser, JsonParsingContext context) throws IOException {
    String fieldName = parser.getCurrentName();
    switch (fieldName) {
        case "offset":
            context.offset = parser.nextIntValue(-1);
            context.doubleValues = null;
            context.stringValues = null;
            break;
        case "uncompressedLength":
            context.uncompressedLength = parser.nextIntValue(-1);
            break;
        case "stepLengths":
            context.stepLengths = new TIntArrayList();
            context.valuesOrLengthArray = true;
            break;
        case "values":
        case "stepValues":
            context.valuesOrLengthArray = true;
            break;
        default:
            break;
    }
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:24,代碼來源:ArrayChunk.java

示例3: 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

示例4: parse

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public LowerCaseNamingPolicyModel parse(JsonParser jsonParser) throws IOException {
    LowerCaseNamingPolicyModel instance = new LowerCaseNamingPolicyModel();
    if (jsonParser.getCurrentToken() == null) {
        jsonParser.nextToken();
    }
    if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
        jsonParser.skipChildren();
        return null;
    }
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        String fieldName = jsonParser.getCurrentName();
        jsonParser.nextToken();
        parseField(instance, fieldName, jsonParser);
        jsonParser.skipChildren();
    }
    return instance;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:LowerCaseNamingPolicyModel$$JsonObjectMapper.java

示例5: parse

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public PrivateFieldModel parse(JsonParser jsonParser) throws IOException {
    PrivateFieldModel instance = new PrivateFieldModel();
    if (jsonParser.getCurrentToken() == null) {
        jsonParser.nextToken();
    }
    if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
        jsonParser.skipChildren();
        return null;
    }
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        String fieldName = jsonParser.getCurrentName();
        jsonParser.nextToken();
        parseField(instance, fieldName, jsonParser);
        jsonParser.skipChildren();
    }
    return instance;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:PrivateFieldModel$$JsonObjectMapper.java

示例6: parse

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public NestedCollectionModel parse(JsonParser jsonParser) throws IOException {
    NestedCollectionModel instance = new NestedCollectionModel();
    if (jsonParser.getCurrentToken() == null) {
        jsonParser.nextToken();
    }
    if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
        jsonParser.skipChildren();
        return null;
    }
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        String fieldName = jsonParser.getCurrentName();
        jsonParser.nextToken();
        parseField(instance, fieldName, jsonParser);
        jsonParser.skipChildren();
    }
    return instance;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:NestedCollectionModel$$JsonObjectMapper.java

示例7: parse

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public SimpleCollectionModel parse(JsonParser jsonParser) throws IOException {
    SimpleCollectionModel instance = new SimpleCollectionModel();
    if (jsonParser.getCurrentToken() == null) {
        jsonParser.nextToken();
    }
    if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
        jsonParser.skipChildren();
        return null;
    }
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        String fieldName = jsonParser.getCurrentName();
        jsonParser.nextToken();
        parseField(instance, fieldName, jsonParser);
        jsonParser.skipChildren();
    }
    return instance;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:SimpleCollectionModel$$JsonObjectMapper.java

示例8: jsonExtractSubnetMask

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
	String subnet_mask = "";
	MappingJsonFactory f = new MappingJsonFactory();
	JsonParser jp;

	try {
		jp = f.createParser(fmJson);
	} catch (JsonParseException e) {
		throw new IOException(e);
	}

	jp.nextToken();
	if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
		throw new IOException("Expected START_OBJECT");
	}

	while (jp.nextToken() != JsonToken.END_OBJECT) {
		if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw new IOException("Expected FIELD_NAME");
		}

		String n = jp.getCurrentName();
		jp.nextToken();
		if (jp.getText().equals(""))
			continue;

		if (n == "subnet-mask") {
			subnet_mask = jp.getText();
			break;
		}
	}

	return subnet_mask;
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:41,代碼來源:FirewallSubnetMaskResource.java

示例9: parsePersons

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public void parsePersons(String filename) {
    try {
        JsonFactory jsonfactory = new JsonFactory();
        File source = new File(filename);
        JsonParser parser = jsonfactory.createParser(source);
        while (parser.nextToken() != JsonToken.END_OBJECT) {
            String token = parser.getCurrentName();
            if ("persons".equals(token)) {
                out.println("Persons found");
                JsonToken jsonToken = parser.nextToken();
                jsonToken = parser.nextToken();
                token = parser.getCurrentName();
                out.println("Next token is " + token);
                if ("groupname".equals(token)) {
                    parser.nextToken();
                    String groupname = parser.getText();
                    out.println("Group : " + groupname);
                    parser.nextToken();
                    token = parser.getCurrentName();
                    if ("person".equals(token)) {
                        out.println("Found person");
                        parsePerson(parser);
                    }
                }
            }
        }
        parser.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:PacktPublishing,項目名稱:Java-for-Data-Science,代碼行數:32,代碼來源:JSONExamples.java

示例10: processToken

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
private JsonToken processToken(JsonToken curToken, JsonParser parser, JsonGenerator jgen)
    throws IOException {
  if (curToken.isStructEnd()) {
    // this is our escape and base case.
    return curToken;
  }
  if (curToken.isStructStart()) {
    processStructStart(curToken, jgen);
    JsonToken token = processToken(parser.nextToken(), parser, jgen);
    while (!token.isStructEnd()) {
      token = processToken(token, parser, jgen);
    }
    processStructEnd(token, jgen);
    return parser.nextToken();
  }

  if (curToken.id() == JsonTokenId.ID_FIELD_NAME) {
    String currentName = parser.getCurrentName();
    if (isFiltered && filters.containsKey(parser.getCurrentName())) {
      jgen.writeFieldName(currentName);
      // perform filtering.
      return filters.get(parser.getCurrentName()).processToken(parser.nextToken(), parser, jgen);
    } else if (!isFiltered) {
      jgen.writeFieldName(currentName);
      return processToken(parser.nextToken(), parser, jgen);
    } else {
      parser.nextToken();
      parser.skipChildren();
      return processToken(parser.nextToken(), parser, jgen);
    }
  } else if (curToken.isScalarValue()) {
    processValue(curToken, parser, jgen);
    return parser.nextToken();
  } else {
    LOGGER.error(
        "Unable to process the token {} with name {}.", curToken, parser.getCurrentName());
    throw new RuntimeException(
        "Unable to process the token " + curToken + " with name" + parser.getCurrentName());
  }
}
 
開發者ID:cerner,項目名稱:beadledom,代碼行數:41,代碼來源:FieldFilter.java

示例11: deserialize

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public NodeDependency deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
    String name = null;
    NodeInfo nodeInfo = null;
    JsonToken token;
    while ((token = jsonParser.nextToken()) != null) {
        if (token == JsonToken.END_OBJECT) {
            break;
        } else if (token == JsonToken.FIELD_NAME) {
            switch (jsonParser.getCurrentName()) {
                case "name":
                    jsonParser.nextToken();
                    name = jsonParser.getValueAsString();
                    break;

                case "nodeInfo":
                    nodeInfo = new NodeInfoJsonDeserializer().deserialize(jsonParser, deserializationContext);
                    break;

                default:
                    throw new AssertionError("Unexpected field: " + jsonParser.getCurrentName());

            }
        }
    }
    if (name == null || nodeInfo == null) {
        throw new IllegalStateException("Inconsistent node dependency json");
    }
    return new NodeDependency(name, nodeInfo);
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:31,代碼來源:NodeDependencyDeserializer.java

示例12: 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

示例13: readDatabase

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
long readDatabase(InputStream stream) throws IOException {
    long timestamp = 0;

    numeriche = new HashMap<>();

    timestamp = System.currentTimeMillis();
    JsonFactory jsonFactory = new JsonFactory(); // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory
    JsonParser jp = jsonFactory.createParser(stream); // or URL, Stream, Reader, String, byte[]

    jp.nextToken(); // will return JsonToken.START_OBJECT (verify?)

    // passo a leggere il database
    String fieldName;
    if (jp.nextToken() == JsonToken.FIELD_NAME) {
        fieldName = jp.getCurrentName();
        jp.nextToken(); // START_OBJECT INIZIO di un nuovo oggetto database

        // Passo al campo nome
        while (jp.nextToken() == JsonToken.FIELD_NAME) {
            fieldName = jp.getCurrentName();
            jp.nextToken(); // Vado al valore
            if ("name".equals(fieldName)) {
                System.out.println("Database Name:" + jp.getValueAsString());
            } else if ("tables".equals(fieldName)) {
                while (jp.nextToken() != JsonToken.END_ARRAY) {
                    readTable(jp);
                }
            }
        }
    }

    jp.close();

    long duration = System.currentTimeMillis() - timestamp;

    return duration;
}
 
開發者ID:claudiodegio,項目名稱:dbsync,代碼行數:38,代碼來源:JsonDatabaseReader.java

示例14: parseFieldName

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
private static void parseFieldName(JsonParser jsonParser, JsonParsingContext parsingContext) throws IOException {
    switch (jsonParser.getCurrentName()) {
        case NodeGenericMetadataJsonSerializer.TYPE:
            jsonParser.nextToken();
            parsingContext.type = jsonParser.getValueAsString();
            break;

        case NodeGenericMetadataJsonSerializer.NAME:
            jsonParser.nextToken();
            parsingContext.name = jsonParser.getValueAsString();
            break;

        case NodeGenericMetadataJsonSerializer.VALUE:
            Objects.requireNonNull(parsingContext.name);
            Objects.requireNonNull(parsingContext.type);
            jsonParser.nextToken();
            switch (parsingContext.type) {
                case NodeGenericMetadataJsonSerializer.STRING:
                    parsingContext.metadata.setString(parsingContext.name, jsonParser.getValueAsString());
                    break;
                case NodeGenericMetadataJsonSerializer.DOUBLE:
                    parsingContext.metadata.setDouble(parsingContext.name, jsonParser.getValueAsDouble());
                    break;
                case NodeGenericMetadataJsonSerializer.INT:
                    parsingContext.metadata.setInt(parsingContext.name, jsonParser.getValueAsInt());
                    break;
                case NodeGenericMetadataJsonSerializer.BOOLEAN:
                    parsingContext.metadata.setBoolean(parsingContext.name, jsonParser.getValueAsBoolean());
                    break;
                default:
                    throw new AssertionError("Unexpected metadata type " + parsingContext.type);
            }
            break;

        default:
            throw new AssertionError("Unexpected field: " + jsonParser.getCurrentName());

    }
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:40,代碼來源:NodeGenericMetadataJsonDeserializer.java

示例15: parsePerson

import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static void parsePerson() {
    try {
        JsonFactory jsonfactory = new JsonFactory();
        JsonParser parser = jsonfactory.createParser(new File("Person.json"));
        while (parser.nextToken() != JsonToken.END_OBJECT) {
            String token = parser.getCurrentName();

            if ("firstname".equals(token)) {
                parser.nextToken();
                String fname = parser.getText();
                out.println("firstname : " + fname);
            }
            if ("lastname".equals(token)) {
                parser.nextToken();
                String lname = parser.getText();
                out.println("lastname : " + lname);
            }
            if ("phone".equals(token)) {
                parser.nextToken();
                long phone = parser.getLongValue();
                out.println("phone : " + phone);
            }
            if ("address".equals(token)) {
                out.println("address :");
                parser.nextToken();
                while (parser.nextToken() != JsonToken.END_ARRAY) {
                    out.println(parser.getText());
                }
            }
        }
        parser.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:PacktPublishing,項目名稱:Java-for-Data-Science,代碼行數:36,代碼來源:JSONExamples.java


注:本文中的com.fasterxml.jackson.core.JsonParser.getCurrentName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。