本文整理匯總了Java中org.codehaus.jackson.JsonParser.getCurrentName方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParser.getCurrentName方法的具體用法?Java JsonParser.getCurrentName怎麽用?Java JsonParser.getCurrentName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.codehaus.jackson.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getCurrentName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
public void parse(HttpRequest req) throws IOException {
final JsonParser parser = jsonFactory.createJsonParser(
new ChannelBufferInputStream(req.getContent()));
parser.nextToken(); // Skip the wrapper
while (parser.nextToken() != JsonToken.END_OBJECT) {
final String metric = parser.getCurrentName();
JsonToken currentToken = parser.nextToken();
if (currentToken == JsonToken.START_OBJECT) {
parseMetricObject(metric, parser);
} else if (currentToken == JsonToken.START_ARRAY) {
int illegalTokens = parseMetricArray(metric, parser);
if(illegalTokens > 0) {
logger.warn("{} illegal tokens encountered", illegalTokens);
}
} else {
logger.warn("Illegal token: expected {} or {}, but was {}: {}",new Object[] {
JsonToken.START_OBJECT, JsonToken.START_ARRAY, currentToken, parser.getText()});
}
}
}
示例2: findDiffProp
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private static void findDiffProp(JsonParser jParser) throws JsonParseException, IOException {
String propName = null;
String val1 = null;
String val2 = null;
while (jParser.nextToken() != JsonToken.END_ARRAY) {
String fieldname = jParser.getCurrentName();
if ("name".equals(fieldname)) {
// System.out.println("iterating children");
jParser.nextToken();
propName = jParser.getText();
}
if ("value1".equals(fieldname)) {
// System.out.println("Diff property");
jParser.nextToken();
val1 = jParser.getText();
}
if ("value2".equals(fieldname)) {
jParser.nextToken();
val2 = jParser.getText();
System.out.println("Diff " + propName + " " + val1 + " -> " + val2);
propDiffCount++;
}
}
}
示例3: deserialize
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public IPv4 deserialize(JsonParser jp,
DeserializationContext ctxt)
throws IOException, JsonProcessingException {
IPv4 ipv4 = null;
jp.nextToken(); // Move to JsonToken.START_OBJECT
while (jp.nextToken() != JsonToken.END_OBJECT) {
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
log.debug("Fieldname: {} Value: {}", fieldname, value);
ipv4 = new IPv4(value);
}
}
return ipv4;
}
示例4: deserialize
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public Dpid deserialize(JsonParser jp,
DeserializationContext ctxt)
throws IOException, JsonProcessingException {
Dpid dpid = null;
jp.nextToken(); // Move to JsonToken.START_OBJECT
while (jp.nextToken() != JsonToken.END_OBJECT) {
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
log.debug("Fieldname: {} Value: {}", fieldname, value);
dpid = new Dpid(value);
}
}
return dpid;
}
示例5: deserialize
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public IPv6 deserialize(JsonParser jp,
DeserializationContext ctxt)
throws IOException, JsonProcessingException {
IPv6 ipv6 = null;
jp.nextToken(); // Move to JsonToken.START_OBJECT
while (jp.nextToken() != JsonToken.END_OBJECT) {
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
log.debug("Fieldname: {} Value: {}", fieldname, value);
ipv6 = new IPv6(value);
}
}
return ipv6;
}
示例6: deserialize
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
@Override
public MACAddress deserialize(JsonParser jp,
DeserializationContext ctxt)
throws IOException, JsonProcessingException {
MACAddress mac = null;
jp.nextToken(); // Move to JsonToken.START_OBJECT
while (jp.nextToken() != JsonToken.END_OBJECT) {
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
log.debug("Fieldname: {} Value: {}", fieldname, value);
mac = MACAddress.valueOf(value);
}
}
return mac;
}
示例7: deserialize
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
public EnumMap<?, ?> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
throws IOException, JsonProcessingException
{
if (paramJsonParser.getCurrentToken() != JsonToken.START_OBJECT)
throw paramDeserializationContext.mappingException(EnumMap.class);
EnumMap localEnumMap = constructMap();
if (paramJsonParser.nextToken() != JsonToken.END_OBJECT)
{
String str = paramJsonParser.getCurrentName();
Enum localEnum = this._enumResolver.findEnum(str);
if (localEnum == null)
throw paramDeserializationContext.weirdStringException(this._enumResolver.getEnumClass(), "value not one of declared Enum instance names");
if (paramJsonParser.nextToken() == JsonToken.VALUE_NULL);
for (Object localObject = null; ; localObject = this._valueDeserializer.deserialize(paramJsonParser, paramDeserializationContext))
{
localEnumMap.put(localEnum, localObject);
break;
}
}
return localEnumMap;
}
示例8: checkMatchFieldName
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
/**
* フィールド名がファイルの形式に一致しているかの確認.
* @param jp
* @param jsonName
* @throws IOException
* @throws JsonParseException
*/
private void checkMatchFieldName(JsonParser jp, String jsonName) throws IOException {
String fieldName = jp.getCurrentName();
if (!(fieldName.equals("Relations") && jsonName.equals(RELATION_JSON))
&& !(fieldName.equals("Roles") && jsonName.equals(ROLE_JSON))
&& !(fieldName.equals("ExtRoles") && jsonName.equals(EXTROLE_JSON))
&& !(fieldName.equals("Links") && jsonName.equals(LINKS_JSON))
&& !(fieldName.equals("Links") && jsonName.equals(USERDATA_LINKS_JSON))) {
throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params(jsonName);
}
}
示例9: getResponseMetadata
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private HashMap<String, String> getResponseMetadata(HttpResponse response, String identifier) throws JsonParseException, IllegalStateException, IOException {
HashMap<String, String> metadata = new HashMap<String, String>();
InputStream content = response.getEntity().getContent();
if (isSuccessfulResponse(response)) {
String key, value = null;
JsonFactory f = new JsonFactory();
JsonParser jp = f.createJsonParser(content);
while ((jp.nextToken()) != JsonToken.END_OBJECT) {
key = jp.getCurrentName();
if ("metadata".equals(key)) {
jp.nextToken();
System.out.println("Start parsing metadata for " + identifier);
while ((jp.nextToken()) != JsonToken.END_OBJECT) {
key = jp.getCurrentName();
jp.nextToken();
value = jp.getText();
metadata.put(key, value);
System.out.println(identifier + " -- Key = " + key + " : Value = " + value);
}
System.out.println("End parsing metadata for " + identifier);
return metadata;
}
}
} else {
String string = IOUtils.toString(content);
System.err.println(string);
}
return metadata;
}
示例10: readWorkerStatus
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private static WorkerStatus readWorkerStatus(JsonParser jParser) throws IOException {
WorkerStatus res = new WorkerStatus();
while (jParser.nextToken() != JsonToken.END_OBJECT) {
switch (jParser.getCurrentName() + "") {
case "workerId":
nextToken(jParser);
res.setWorkerId(readValue(jParser));
break;
case "location":
nextToken(jParser);
res.setWorkerLocation(readValue(jParser));
break;
case "processId":
nextToken(jParser);
res.setProcessId(readValue(jParser));
break;
case "status":
nextToken(jParser);
res.setStatus(Integer.parseInt(readValue(jParser)));
break;
case "lastConnectionTs":
nextToken(jParser);
res.setLastConnectionTs(Long.parseLong(readValue(jParser)));
break;
default:
throw new IOException("Unexpected field " + jParser.getCurrentName());
}
}
return res;
}
示例11: readTransaction
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private static Transaction readTransaction(JsonParser jParser) throws IOException {
long creationTimestamp = 0;
long id = 0;
List<Task> preparedTasks = new ArrayList<>();
while (jParser.nextToken() != JsonToken.END_OBJECT) {
switch (jParser.getCurrentName() + "") {
case "creationTimestamp":
nextToken(jParser);
creationTimestamp = Long.parseLong(readValue(jParser));
break;
case "id":
nextToken(jParser);
id = Long.parseLong(readValue(jParser));
break;
case "preparedTasks":
nextToken(jParser);
while (jParser.nextToken() != JsonToken.END_ARRAY) {
Task task = readTask(jParser);
preparedTasks.add(task);
}
break;
default:
throw new IOException("Unexpected field " + jParser.getCurrentName());
}
}
Transaction res = new Transaction(id, creationTimestamp);
if (!preparedTasks.isEmpty()) {
res.getPreparedTasks().addAll(preparedTasks);
}
return res;
}
示例12: readCodePool
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
private static CodePool readCodePool(JsonParser jParser) throws IOException {
long creationTimestamp = 0;
String id = "";
long ttl = 0;
byte[] payload = null;
while (jParser.nextToken() != JsonToken.END_OBJECT) {
switch (jParser.getCurrentName() + "") {
case "creationTimestamp":
nextToken(jParser);
creationTimestamp = Long.parseLong(readValue(jParser));
break;
case "ttl":
nextToken(jParser);
ttl = Long.parseLong(readValue(jParser));
break;
case "id":
nextToken(jParser);
id = readValue(jParser);
break;
case "data":
nextToken(jParser);
String base64data = readValue(jParser);
payload = Base64.getDecoder().decode(base64data);
break;
default:
throw new IOException("Unexpected field " + jParser.getCurrentName());
}
}
return new CodePool(id, creationTimestamp, payload, ttl);
}
示例13: jsonToHostDefinition
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
try {
jp = f.createJsonParser(json);
} 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;
else if (n.equals("attachment")) {
while (jp.nextToken() != JsonToken.END_OBJECT) {
String field = jp.getCurrentName();
if (field.equals("id")) {
host.attachment = jp.getText();
} else if (field.equals("mac")) {
host.mac = jp.getText();
}
}
}
}
jp.close();
}
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:39,代碼來源:HostResource.java
示例14: getEntryNameFromJson
import org.codehaus.jackson.JsonParser; //導入方法依賴的package包/類
/**
* Gets the entry name of a flow mod
* @param fmJson The OFFlowMod in a JSON representation
* @return The name of the OFFlowMod, null if not found
* @throws IOException If there was an error parsing the JSON
*/
public static String getEntryNameFromJson(String fmJson) throws IOException{
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
try {
jp = f.createJsonParser(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 == "name")
return jp.getText();
}
return null;
}
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:38,代碼來源:StaticFlowEntries.java
示例15: jsonExtractSubnetMask
import org.codehaus.jackson.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.createJsonParser(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:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:41,代碼來源:FirewallResource.java