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