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


Java JsonArray类代码示例

本文整理汇总了Java中com.google.gson.JsonArray的典型用法代码示例。如果您正苦于以下问题:Java JsonArray类的具体用法?Java JsonArray怎么用?Java JsonArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: toJson

import com.google.gson.JsonArray; //导入依赖的package包/类
@Override
public JsonObject toJson() {
    JsonObject jsonFilter = new JsonObject();

    JsonArray jsonPropertyPredicates = new JsonArray();
    for (QueryPredicate queryPredicate : queryPredicates) {
        jsonPropertyPredicates.add(queryPredicate.toJson());
    }
    JsonArray jsonArguments = new JsonArray();
    JsonObject jsonArgument = new JsonObject();
    jsonArgument.addProperty(JsonKeyConstants.NAME.toString(), "Vertex Indices");
    jsonArgument.add(JsonKeyConstants.VALUE.toString(), jsonPropertyPredicates);
    jsonArguments.add(jsonArgument);
    jsonFilter.addProperty(JsonKeyConstants.NAME.toString(), "Filter (σ)");
    jsonFilter.add(JsonKeyConstants.ARGS.toString(), jsonArguments);

    return jsonFilter;
}
 
开发者ID:graphflow,项目名称:graphflow,代码行数:19,代码来源:Filter.java

示例2: keypointsToJSON

import com.google.gson.JsonArray; //导入依赖的package包/类
public String keypointsToJSON(MatOfKeyPoint kps){
    Gson gson = new Gson();

    JsonArray jsonArr = new JsonArray();

    KeyPoint[] kpsArray = kps.toArray();
    for(KeyPoint kp : kpsArray){
        JsonObject obj = new JsonObject();

        obj.addProperty("class_id", kp.class_id);
        obj.addProperty("x", kp.pt.x);
        obj.addProperty("y", kp.pt.y);
        obj.addProperty("size", kp.size);
        obj.addProperty("angle", kp.angle);
        obj.addProperty("octave", kp.octave);
        obj.addProperty("response", kp.response);

        jsonArr.add(obj);
    }

    return gson.toJson(jsonArr);
}
 
开发者ID:jorenham,项目名称:fingerblox,代码行数:23,代码来源:ImageDisplayActivity.java

示例3: deserialize

import com.google.gson.JsonArray; //导入依赖的package包/类
@Override
public GeometryCollectionDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {

	GeometryCollectionDto dto = new GeometryCollectionDto();
	List<GeometryDto> geometries = new ArrayList<>();
	dto.setGeometries(geometries);

	JsonObject asJsonObject = json.getAsJsonObject();
	JsonArray jsonArray = asJsonObject.get("geometries").getAsJsonArray();
	if (jsonArray == null) {
		return dto;
	}

	for (int i = 0; i < jsonArray.size(); i++) {
		JsonObject geometryElement = jsonArray.get(i).getAsJsonObject();
		String typeOfGeometry = geometryElement.get("type").getAsString();
		GeoJSONObjectTypeEnum typeEnum = GeoJSONObjectTypeEnum.valueOf(typeOfGeometry);

		GeometryDto geometryDto = context.deserialize(geometryElement, typeEnum.getDtoClass());
		geometries.add(geometryDto);
	}

	dto.setBbox(BoundingBoxParser.parseBbox(asJsonObject, context));

	return dto;
}
 
开发者ID:mokszr,项目名称:ultimate-geojson,代码行数:27,代码来源:GeometryCollectionDeserializer.java

示例4: build

import com.google.gson.JsonArray; //导入依赖的package包/类
public Call<InsertResult<R>, DBException> build() {
    /* Create the query object */
    this.insObjs.add(this.currentObj);
    JsonObject query = new JsonObject();
    query.add("objects", this.insObjs);
    JsonArray retArr = new JsonArray();
    for (String retCol : this.retSet)
        retArr.add(new JsonPrimitive(retCol));
    query.add("returning", retArr);

    String opUrl = "/table/" + table.getTableName() + "/insert";

    Converter<InsertResult<R>, DBException> converter
            = new DBResponseConverter<>(table.getInsResType());
    return db.mkCall(opUrl, db.gson.toJson(query), converter);
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:17,代码来源:InsertQuery.java

示例5: interpret

import com.google.gson.JsonArray; //导入依赖的package包/类
@Override
public InterpreterResult interpret(String gremlin, InterpreterContext interpreterContext) {
    logger.info("execute gremlin traversal {}", gremlin);
    try {
        ResultSet results = client.submit(gremlin);
        JsonArray array = results.stream()
                                 .map(result -> new JsonPrimitive(results.toString()))
                                 .collect(JsonArray::new, JsonArray::add, JsonArray::addAll);

        //TODO extract ResultSet
        //Case MessageSerializer

        return new InterpreterResult(InterpreterResult.Code.SUCCESS, array.toString());
    } catch (RuntimeException e) {
        return new InterpreterResult(InterpreterResult.Code.ERROR, e.getMessage());
    }
}
 
开发者ID:shikeio,项目名称:gremzeppelin,代码行数:18,代码来源:GremlinInterpreter.java

示例6: updatetag

import com.google.gson.JsonArray; //导入依赖的package包/类
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public Integer updatetag(Integer tId) {
    //标签
    List<Tag> tags = tagMapper.getAllTags();
    JsonArray jsonArray = new JsonArray();
    for (Tag tag : tags) {
        List<Blog> blogs = tagMapper.getblogbytagid(tag.gettId());
        String str = tag.gettName() + " " + "(" + String.valueOf(blogs.size()) + ")";
        KeyAndValue keyAndValue = new KeyAndValue();
        keyAndValue.setKey(tag.gettName());
        keyAndValue.setValue(str);
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("key", tag.gettId());
        jsonObject.addProperty("value", str);
        jsonArray.add(jsonObject);
    }
    boolean result = redisTemplate.execute((RedisCallback<Boolean>) connection -> {
        RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
        connection.set(serializer.serialize("biaoqian"), serializer.serialize(jsonArray.toString()));
        return true;
    });
    return tId;
}
 
开发者ID:Zephery,项目名称:newblog,代码行数:25,代码来源:TagServiceImpl.java

示例7: loadConfiguration

import com.google.gson.JsonArray; //导入依赖的package包/类
@Override
public void loadConfiguration(JsonArray rootJson)
{
    if (rootJson.size() == 0)
        return;

    for (int i = 0; i < rootJson.size(); i++)
    {
        JsonObject graouJson = rootJson.get(i).getAsJsonObject();

        Location catLocation = LocationUtils.str2loc(graouJson.get("cat").getAsString());
        Location doorLocation = LocationUtils.str2loc(graouJson.get("door").getAsString());
        Location treasureLocation = LocationUtils.str2loc(graouJson.get("treasure").getAsString());
        Location openingLocation = LocationUtils.str2loc(graouJson.get("opening").getAsString());

        Graou graou = new Graou(this.hub, catLocation, doorLocation, treasureLocation, openingLocation);

        this.interactions.add(graou);
        this.log(Level.INFO, "Registered Graou at '" + graouJson.get("cat").getAsString());
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:22,代码来源:GraouManager.java

示例8: verifyRegistrationTags

import com.google.gson.JsonArray; //导入依赖的package包/类
@Test
public void verifyRegistrationTags() throws IOException {
    JsonObject json = manager.buildJsonRequest();
    JsonArray tags = (JsonArray) json.get("Tags");
    assertThat(tags).hasSize(7);
    assertThat(tags).contains(new JsonPrimitive(
            "t-789cab562aa92c4855b2522acdcbcecb2fcf53aa05003d1c068d"));
    assertThat(tags).contains(new JsonPrimitive(
            "t-789cab562a294acc2b2ec82f2a51b252ca28292950aa05004f930768"));
    assertThat(tags).contains(new JsonPrimitive(
            "t-789cab564a2acacf4e2d52b252ca28292950aa0500364d0600"));
    assertThat(tags).contains(new JsonPrimitive(
            "t-789cab562a4e2d2a4b2d52b2522a2a4856aa050030dd0597"));
    assertThat(tags).contains(new JsonPrimitive(
            "t-789cab562a4a4dcf2c2e29aa54b2524acecf2b2ecd51aa0500560f07c8"));
    assertThat(tags).contains(new JsonPrimitive(
            "v-789c33d033d033d04d83000016c103e4"));
    assertThat(tags).contains(new JsonPrimitive("e-789cc58fbb0e02211045ff656a4a63c167d81" +
            "a63461957121eeb001bcd867f179275616d2ced269739c3b93338b4041222850802981ea94e" +
            "72fe3c1c9644407c8ddb6042532690c77539104ffa4a674bf1ee55634264ed860e71c9982c3" +
            "aaedc740574c95e881b78d34f52fbdd3779ca55358cde05dab82e5127bb26ffb36d24317bfe" +
            "f5512d57945061c45aae6c11da7a1e4d6992f31bda579619"));
}
 
开发者ID:Sixt,项目名称:ja-micro,代码行数:24,代码来源:RegistrationManagerTest.java

示例9: parse

import com.google.gson.JsonArray; //导入依赖的package包/类
@Override
public IRecipe parse(JsonContext context, JsonObject json) {
    int clamp = JsonUtils.getInt(json, "clamp");
    boolean combining = JsonUtils.getBoolean(json, "combining");

    JsonArray upgradeList = JsonUtils.getJsonArray(json, "upgrades");
    Map<Ingredient, Double> upgrades = new LinkedHashMap<>();
    int n = 0;
    for (JsonElement element : upgradeList) {
        if (element.isJsonObject()) {
            JsonObject upgrade = element.getAsJsonObject();
            double amount = JsonUtils.getFloat(upgrade, "amount");
            Ingredient ingredient = CraftingHelper.getIngredient(upgrade.get("ingredient"), context);
            upgrades.put(ingredient, amount);
        } else {
            throw new JsonSyntaxException("Expected " + n + " to be a JsonObject, was " + JsonUtils.toString(json));
        }
        n++;
    }

    return new RandoresForgeUpgradeRecipe(clamp, combining, upgrades);
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:23,代码来源:RandoresForgeUpgradeRecipeFactory.java

示例10: getData

import com.google.gson.JsonArray; //导入依赖的package包/类
public void getData() {
    LoginData loginData = (LoginData) aCache.getAsObject(ACacheKey.CURRENT_ACCOUNT);
    addSubscription(apiStores.GetCsgData(loginData.getToken(), 1, 2), new ApiCallback<BaseModel<JsonArray>>(delegate.getActivity()) {
        @Override
        public void onSuccess(BaseModel<JsonArray> model) {
            F.e(model.getData().toString());
            GsonBuilder gsonBuilder = new GsonBuilder();
            Gson gson = gsonBuilder.create();
            ArrayList<CSGDynamic> datas = gson.fromJson(model.getData(), new TypeToken<ArrayList<CSGDynamic>>() {
            }.getType());
            delegate.setData(datas);

        }

        @Override
        public void onFailure(String msg) {
            ToastUtil.showToast(msg, delegate.getActivity());
        }

        @Override
        public void onFinish() {
        }
    });
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:25,代码来源:DynamicPresenter.java

示例11: serialize

import com.google.gson.JsonArray; //导入依赖的package包/类
public JsonElement serialize(ServerStatusResponse.PlayerCountData p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
{
    JsonObject jsonobject = new JsonObject();
    jsonobject.addProperty("max", (Number)Integer.valueOf(p_serialize_1_.getMaxPlayers()));
    jsonobject.addProperty("online", (Number)Integer.valueOf(p_serialize_1_.getOnlinePlayerCount()));

    if (p_serialize_1_.getPlayers() != null && p_serialize_1_.getPlayers().length > 0)
    {
        JsonArray jsonarray = new JsonArray();

        for (int i = 0; i < p_serialize_1_.getPlayers().length; ++i)
        {
            JsonObject jsonobject1 = new JsonObject();
            UUID uuid = p_serialize_1_.getPlayers()[i].getId();
            jsonobject1.addProperty("id", uuid == null ? "" : uuid.toString());
            jsonobject1.addProperty("name", p_serialize_1_.getPlayers()[i].getName());
            jsonarray.add(jsonobject1);
        }

        jsonobject.add("sample", jsonarray);
    }

    return jsonobject;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:ServerStatusResponse.java

示例12: getDataElementMapping

import com.google.gson.JsonArray; //导入依赖的package包/类
public static List<DataElement> getDataElementMapping (String filePath) throws Exception
{
    List<DataElement> listDataElement=new ArrayList<>();
    Gson gson=new Gson();
    try {
        JsonArray json=(JsonArray)gson.fromJson(new FileReader(filePath), JsonElement.class);
        for(int iterator=0;iterator<json.size();iterator++)
        {
            JsonElement oElement=json.get(iterator);
            DataElement oDataElement=gson.fromJson(oElement,DataElement.class);
            listDataElement.add(oDataElement);

        }
        //System.out.print(0);
    }
    catch (Exception exc)
    {
        throw new Exception(exc.toString());
    }
    return listDataElement;
}
 
开发者ID:gerard-bisama,项目名称:DHIS2-fhir-lab-app,代码行数:22,代码来源:FhirMediatorUtilities.java

示例13: matchService

import com.google.gson.JsonArray; //导入依赖的package包/类
private static Entry<String, JsonElement> matchService(Set<Entry<String, JsonElement>> entries, String serviceName) {
	for (Entry<String, JsonElement> eachEntry : entries) {
                       // CF service with 'cloudant' in the name
		if (eachEntry.getKey().toLowerCase().contains(serviceName)) {
			return eachEntry;
		}
		// user-provided service with 'cloudant' in the name
		if (eachEntry.getKey().equals("user-provided")) {
			JsonArray upss = eachEntry.getValue().getAsJsonArray();
			for (JsonElement ups : upss) {
				String name = ups.getAsJsonObject().get("name").getAsString();
				if (name.toLowerCase().contains(serviceName)) {
					return eachEntry;
				}
			}
		}
	}
	return null;
}
 
开发者ID:IBM-Cloud,项目名称:get-started-java,代码行数:20,代码来源:VCAPHelper.java

示例14: remove

import com.google.gson.JsonArray; //导入依赖的package包/类
public void remove(Bindings solution) {
	if (solution == null) return;
	JsonArray bindings = getBindingsArray();
	if (bindings == null) return;
	
	bindings.remove(solution.toJson());
}
 
开发者ID:vaimee,项目名称:sepatools,代码行数:8,代码来源:BindingsResults.java

示例15: loadConfiguration

import com.google.gson.JsonArray; //导入依赖的package包/类
@Override
public void loadConfiguration(JsonArray rootJson)
{
    for (int i = 0; i < rootJson.size(); i++)
    {
        JsonElement jsonBumber = rootJson.get(i);

        Bumper bumper = null;

        try
        {
            bumper = new Bumper(this.hub, jsonBumber.getAsString());
        }
        catch (Exception ignored) {}

        if (bumper != null)
        {
            this.interactions.add(bumper);
            this.log(Level.INFO, "Registered bumper at '" + jsonBumber.getAsString());
        }
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:23,代码来源:BumperManager.java


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