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


Java JsonObject.entrySet方法代码示例

本文整理汇总了Java中com.google.gson.JsonObject.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.entrySet方法的具体用法?Java JsonObject.entrySet怎么用?Java JsonObject.entrySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gson.JsonObject的用法示例。


在下文中一共展示了JsonObject.entrySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseValues

import com.google.gson.JsonObject; //导入方法依赖的package包/类
public static List<KvEntry> parseValues(JsonObject valuesObject) {
  List<KvEntry> result = new ArrayList<>();
  for (Entry<String, JsonElement> valueEntry : valuesObject.entrySet()) {
    JsonElement element = valueEntry.getValue();
    if (element.isJsonPrimitive()) {
      JsonPrimitive value = element.getAsJsonPrimitive();
      if (value.isString()) {
        result.add(new StringDataEntry(valueEntry.getKey(), value.getAsString()));
      } else if (value.isBoolean()) {
        result.add(new BooleanDataEntry(valueEntry.getKey(), value.getAsBoolean()));
      } else if (value.isNumber()) {
        if (value.getAsString().contains(".")) {
          result.add(new DoubleDataEntry(valueEntry.getKey(), value.getAsDouble()));
        } else {
          result.add(new LongDataEntry(valueEntry.getKey(), value.getAsLong()));
        }
      } else {
        throw new JsonSyntaxException("Can't parse value: " + value);
      }
    } else {
      throw new JsonSyntaxException("Can't parse value: " + element);
    }
  }
  return result;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:26,代码来源:JsonConverter.java

示例2: getAsCollection

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Override
public <T, C extends Collection<T>> void getAsCollection(String key, Class<T> type, C collection)
{
    JsonElement element = this.getElement(this.element, key);
    if (element == null)
    {
        throw new DeserializationException(type, this, "Can't find valid value for key: " + key);
    }
    if (element.isJsonArray())
    {
        JsonArray jsonArray = element.getAsJsonArray();
        for (JsonElement jsonElement : jsonArray)
        {
            collection.add(this.deserializeSpecial(type, jsonElement, null));
        }
    }
    else if (element.isJsonObject())
    {
        JsonObject jsonObject = element.getAsJsonObject();
        for (Entry<String, JsonElement> entry : jsonObject.entrySet())
        {
            collection.add(this.deserializeSpecial(type, entry.getValue(), null));
        }
    }
    else
    {
        throw new DeserializationException(type, this, "Can't find valid value for key: " + key);
    }
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:30,代码来源:JsonDeserializationData.java

示例3: parseScripts

import com.google.gson.JsonObject; //导入方法依赖的package包/类
public static final List<String> parseScripts(File f) {
    List<String> list = new ArrayList<>();
    if(!f.exists()) {
        return list;
    }

    try {
        JsonObject result = new Gson().fromJson(FileUtil.loadFile(f, "UTF-8"), JsonObject.class);
        JsonObject scripts = result.getAsJsonObject("scripts");
        if(scripts == null) {
            return list;// Fix NPE when there is an empty or no scripts package.json file
        }
        for (Map.Entry<String, JsonElement> obj:
                scripts.entrySet()) {
            list.add(obj.getKey());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return list;
}
 
开发者ID:beansoftapp,项目名称:react-native-console,代码行数:23,代码来源:NPMParser.java

示例4: writeObservationsToJSON

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@Override
public void writeObservationsToJSON(JsonObject json, MissionInit missionInit)
{
   	String jsonstring = "";
   	synchronized (this.latestJsonStats)
   	{
   		jsonstring = this.latestJsonStats;
	}
   	if (jsonstring.length() > 2)	// "{}" is the empty JSON string.
   	{
   		// Parse the string into json:
   		JsonParser parser = new JsonParser();
   		JsonElement root = parser.parse(jsonstring);
   		// Now copy the children of root into the provided json object:
   		if (root.isJsonObject())
   		{
   			JsonObject rootObj = root.getAsJsonObject();
			for (Map.Entry<String, JsonElement> entry : rootObj.entrySet())
			{
				json.add(entry.getKey(), entry.getValue());
			}
   		}
   	}
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:25,代码来源:ObservationFromServer.java

示例5: parseFaces

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private Map<EnumFacing, BlockPartFace> parseFaces(JsonDeserializationContext deserializationContext, JsonObject object)
{
    Map<EnumFacing, BlockPartFace> map = Maps.newEnumMap(EnumFacing.class);
    JsonObject jsonobject = JsonUtils.getJsonObject(object, "faces");

    for (Entry<String, JsonElement> entry : jsonobject.entrySet())
    {
        EnumFacing enumfacing = this.parseEnumFacing((String)entry.getKey());
        map.put(enumfacing, (BlockPartFace)deserializationContext.deserialize((JsonElement)entry.getValue(), BlockPartFace.class));
    }

    return map;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:14,代码来源:BlockPart.java

示例6: serializeFeedbackData

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private void serializeFeedbackData(NavigationFeedbackEvent src, JsonSerializationContext context,
                                   JsonObject feedbackEvent) {
  JsonObject feedbackData = context.serialize(src.getFeedbackData()).getAsJsonObject();
  for (Map.Entry<String, JsonElement> e : feedbackData.entrySet()) {
    feedbackEvent.add(e.getKey(), e.getValue());
  }
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:8,代码来源:FeedbackEventSerializer.java

示例7: parseResource

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private static Resource parseResource(JsonObject object, String name, Resource parent) {
	ResourceMock resource = new ResourceMock(parent, name);
	for (Entry<String, JsonElement> entry : object.entrySet()) {
		resource.addChild(parseResource(entry.getValue(), entry.getKey(), resource));
	}
	return resource;
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-query,代码行数:8,代码来源:JsonToResource.java

示例8: parseFaces

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private Map<EnumFacing, BlockPartFace> parseFaces(JsonDeserializationContext p_178253_1_, JsonObject p_178253_2_)
{
    Map<EnumFacing, BlockPartFace> map = Maps.newEnumMap(EnumFacing.class);
    JsonObject jsonobject = JsonUtils.getJsonObject(p_178253_2_, "faces");

    for (Entry<String, JsonElement> entry : jsonobject.entrySet())
    {
        EnumFacing enumfacing = this.parseEnumFacing((String)entry.getKey());
        map.put(enumfacing, (BlockPartFace)p_178253_1_.deserialize((JsonElement)entry.getValue(), BlockPartFace.class));
    }

    return map;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:14,代码来源:BlockPart.java

示例9: deserialize

import com.google.gson.JsonObject; //导入方法依赖的package包/类
public LanguageMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    Set<Language> set = Sets.<Language>newHashSet();

    for (Entry<String, JsonElement> entry : jsonobject.entrySet())
    {
        String s = (String)entry.getKey();
        JsonObject jsonobject1 = JsonUtils.getJsonObject((JsonElement)entry.getValue(), "language");
        String s1 = JsonUtils.getString(jsonobject1, "region");
        String s2 = JsonUtils.getString(jsonobject1, "name");
        boolean flag = JsonUtils.getBoolean(jsonobject1, "bidirectional", false);

        if (s1.isEmpty())
        {
            throw new JsonParseException("Invalid language->\'" + s + "\'->region: empty value");
        }

        if (s2.isEmpty())
        {
            throw new JsonParseException("Invalid language->\'" + s + "\'->name: empty value");
        }

        if (!set.add(new Language(s, s1, s2, flag)))
        {
            throw new JsonParseException("Duplicate language->\'" + s + "\' defined");
        }
    }

    return new LanguageMetadataSection(set);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:32,代码来源:LanguageMetadataSectionSerializer.java

示例10: serializeChatStyle

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private void serializeChatStyle(ChatStyle style, JsonObject object, JsonSerializationContext ctx)
{
    JsonElement jsonelement = ctx.serialize(style);

    if (jsonelement.isJsonObject())
    {
        JsonObject jsonobject = (JsonObject)jsonelement;

        for (Entry<String, JsonElement> entry : jsonobject.entrySet())
        {
            object.add((String)entry.getKey(), (JsonElement)entry.getValue());
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:15,代码来源:IChatComponent.java

示例11: serializeChatStyle

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private void serializeChatStyle(Style style, JsonObject object, JsonSerializationContext ctx)
{
    JsonElement jsonelement = ctx.serialize(style);

    if (jsonelement.isJsonObject())
    {
        JsonObject jsonobject = (JsonObject)jsonelement;

        for (Entry<String, JsonElement> entry : jsonobject.entrySet())
        {
            object.add((String)entry.getKey(), (JsonElement)entry.getValue());
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:ITextComponent.java

示例12: Mutation

import com.google.gson.JsonObject; //导入方法依赖的package包/类
public Mutation(JsonObject fields) throws SchemaViolationError {
    for (Map.Entry<String, JsonElement> field : fields.entrySet()) {
        String key = field.getKey();
        String fieldName = getFieldName(key);
        switch (fieldName) {
            case "set_integer": {
                responseData.put(key, jsonAsBoolean(field.getValue(), key));

                break;
            }

            case "set_string": {
                responseData.put(key, jsonAsBoolean(field.getValue(), key));

                break;
            }

            case "set_string_with_default": {
                responseData.put(key, jsonAsBoolean(field.getValue(), key));

                break;
            }

            case "__typename": {
                responseData.put(key, jsonAsString(field.getValue(), key));
                break;
            }
            default: {
                throw new SchemaViolationError(this, key, field.getValue());
            }
        }
    }
}
 
开发者ID:Shopify,项目名称:graphql_java_gen,代码行数:34,代码来源:Generated.java

示例13: makeMapResourceValues

import com.google.gson.JsonObject; //导入方法依赖的package包/类
protected Map<ResourceLocation, Float> makeMapResourceValues(JsonObject p_188025_1_)
{
    Map<ResourceLocation, Float> map = Maps.<ResourceLocation, Float>newLinkedHashMap();
    JsonObject jsonobject = JsonUtils.getJsonObject(p_188025_1_, "predicate");

    for (Entry<String, JsonElement> entry : jsonobject.entrySet())
    {
        map.put(new ResourceLocation((String)entry.getKey()), Float.valueOf(JsonUtils.getFloat((JsonElement)entry.getValue(), (String)entry.getKey())));
    }

    return map;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:ItemOverride.java

示例14: parseRoomEvents

import com.google.gson.JsonObject; //导入方法依赖的package包/类
private void parseRoomEvents(JsonObject syncData) throws RestfulHTTPException, IOException {
	if(syncData.has("rooms") &&
			syncData.get("rooms").isJsonObject()) {

		JsonObject roomsData = syncData.get("rooms").getAsJsonObject();

		if(roomsData.has("join") &&
				roomsData.get("join").isJsonObject()) {
			JsonObject joinEvents = roomsData.get("join").getAsJsonObject();
			for(Map.Entry<String, JsonElement> joinEventEntry : joinEvents.entrySet()) {
				if(joinEventEntry.getValue().isJsonObject()) {
					String roomId = joinEventEntry.getKey();
					JsonObject joinEvent = joinEventEntry.getValue().getAsJsonObject();
					Room room;
					if(joinRooms.containsKey(roomId)) {
						room = joinRooms.get(roomId);
					}else{
						room = new Room(api, users, roomId);
					}
					room.update(joinEvent);
					joinRooms.put(roomId, room);
				}
			}
		}

		// TODO: "leave"-rooms
		// TODO: "invite"-rooms
	}
}
 
开发者ID:Gurgy,项目名称:Cypher,代码行数:30,代码来源:Client.java

示例15: Plain

import com.google.gson.JsonObject; //导入方法依赖的package包/类
@SuppressWarnings("WeakerAccess")
public Plain(String json) {
    List<JsonTable> list = new ArrayList<>();
    if (StringUtils.isNoneEmpty(json)) {
        final JsonParser parser = new JsonParser();
        final JsonObject jsonObject = parser.parse(json).getAsJsonObject();
        for (Map.Entry<String, JsonElement> e : jsonObject.entrySet()) {
            if (e.getValue().isJsonArray()) {
                list.add(new JsonTable(e.getKey(), e.getValue().getAsJsonArray()));
            }
        }
    }
    jsonLength = json.length();
    iterator = list.iterator();
}
 
开发者ID:terma,项目名称:sql-on-json,代码行数:16,代码来源:Plain.java


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