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


Java JsonArray.toString方法代码示例

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


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

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

示例2: makeJSON

import com.google.gson.JsonArray; //导入方法依赖的package包/类
public String makeJSON(Object[][] in) {
    JsonArray outerArray = new JsonArray();
    for (int i = 0; i < in.length; i++) {
        JsonArray innerArray = new JsonArray();
        for (int j = 0; j < in[i].length; j++) {
            Object a = in[i][j];
            Class objectClass = a.getClass();
            if (objectClass == String.class) {
                innerArray.add(in[i][j].toString());
            } else if (Number.class.isAssignableFrom(objectClass)) {
                innerArray.add((Number) in[i][j]);
            } else if (objectClass == JsonElement.class) {
                innerArray.add((JsonElement) in[i][j]);
            } else {
                throw new RuntimeException("WHAT ARE YOU");
            }
        }

        outerArray.add(innerArray);
    }
    return outerArray.toString();
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-3-sixguysburgers-fries,代码行数:23,代码来源:PlantController.java

示例3: getRawPostBean

import com.google.gson.JsonArray; //导入方法依赖的package包/类
private List<RawPostBean> getRawPostBean(String data){
        if (data == null){
            Log.i(TAG,"string 为空");
            return null;
        }
        JsonParser jsonParser = new JsonParser();
        JsonArray jsonArray = jsonParser.parse(data).getAsJsonArray();
        String string = jsonArray.toString();
        if (!jsonArray.isJsonNull()){
            //保存 json 供下次打开时读取缓存中的图片
            //只在刷新时保存
            if (this.mPage == 1 && mType.equals("post")){
                Log.i(TAG, mType);
                new FileUtils().saveJson(string);
            }
            Log.i(TAG, mType);
            //转换为 List<RawPostBean>
            for (JsonElement post : jsonArray){
                RawPostBean rawPostBean = mGson.fromJson(post, RawPostBean.class);
                mRawPostBeanList.add(rawPostBean);
            }

//        Log.i("TAGS", String.valueOf(postBeanList.get(0).getTags().size()));
            return mRawPostBeanList;
        }
        Log.i("getPostBean","结果为空");
        return null;
    }
 
开发者ID:fiepi,项目名称:moebooru-android,代码行数:29,代码来源:GetPost.java

示例4: makeJSON

import com.google.gson.JsonArray; //导入方法依赖的package包/类
/**
 * Creates a two dimensional Json array from an Object[][] in.
 *
 * Valid Objects to put in the Object[][] are Strings, Numbers (bool, integer, double, etc.), and JsonElements
 *
 * @param in
 * @return
 */
public String makeJSON(Object[][] in) {

    JsonArray outerArray = new JsonArray();
    for(int i = 0; i < in.length; i++) {
        JsonArray innerArray = new JsonArray();
        for(int j = 0; j < in[i].length; j++) {
            Object a = in[i][j];
            Class objectClass = a.getClass();
            if(objectClass == String.class)
            {
                innerArray.add(in[i][j].toString());
            }
            else if(Number.class.isAssignableFrom(objectClass))
            {
                innerArray.add((Number)in[i][j]);
            }
            else if(objectClass == JsonElement.class)
            {
                innerArray.add((JsonElement)in[i][j]);
            }
            else
            {
                throw new RuntimeException("WHAT ARE YOU");
            }
        }

        outerArray.add(innerArray);
    }
    return outerArray.toString();
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-revolverenguardia-1,代码行数:39,代码来源:GardenCharts.java

示例5: manifest

import com.google.gson.JsonArray; //导入方法依赖的package包/类
/**
 * Create the appropriate manifest structure for a static large object (SLO).
 * The number of object segments is limited to a configurable amount, default 1000. Each segment,
 * except for the final one, must be at least 1 megabyte (configurable).
 *
 * @param objects Ordered list of segments
 * @return ETag returned by the simple upload total size of segment uploaded path of segment
 */
public String manifest(final String container, final List<StorageObject> objects) {
    JsonArray manifestSLO = new JsonArray();
    for(StorageObject s : objects) {
        JsonObject segmentJSON = new JsonObject();
        // this is the container and object name in the format {container-name}/{object-name}
        segmentJSON.addProperty("path", String.format("/%s/%s", container, s.getName()));
        // MD5 checksum of the content of the segment object
        segmentJSON.addProperty("etag", s.getMd5sum());
        segmentJSON.addProperty("size_bytes", s.getSize());
        manifestSLO.add(segmentJSON);
    }
    return manifestSLO.toString();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:22,代码来源:SwiftSegmentService.java

示例6: fetchColumnsForMultipleTables

import com.google.gson.JsonArray; //导入方法依赖的package包/类
@RequestMapping(value = "/fetchColumnsForMultipleTables")
public void fetchColumnsForMultipleTables(HttpServletRequest request, HttpServletResponse response) throws IOException {
	logger.info("Inside fetchColumnsForMultipleTables");
	String jsonColumnsDtl = "";
	List<String> tableNameList = null;
	JsonArray jsonArray = new JsonArray();
	Gson gson = new Gson();
	String tableName = request.getParameter("tableName").trim().equalsIgnoreCase("") ? ""
			: request.getParameter("tableName").trim();
	logger.info("Fetch column for TableName : " + tableName);
	String sourceDatabaseName = request.getParameter("sourceDatabaseName");
	logger.info("Source DB is:" + sourceDatabaseName);
	String sourceDatabaseSchema = request.getParameter("sourceDatabaseSchema");
	logger.info("Source schema is:" + sourceDatabaseSchema);
	if(tableName != null && !tableName.isEmpty()){
		tableNameList = Arrays.asList(tableName.split(","));
	}
	DatabaseDetailsService databaseDetailsService = new DatabaseDetailsServiceImpl();
	Map<String, Object> outPut = databaseDetailsService.fetchColumnsForMultipleTables(sourceDatabaseName,sourceDatabaseSchema, tableNameList);
	if (SyncConstants.SUCCESS.equalsIgnoreCase(String.valueOf(outPut.get("result")))) {
		@SuppressWarnings("unchecked")
		Map<String, OracleColumn> columnsMap = (Map<String, OracleColumn>) outPut.get("output");
		for(Entry<String,OracleColumn> entry : columnsMap.entrySet()){
			JsonObject obj = new JsonObject();
			obj.addProperty("tableName", entry.getKey());
			JsonElement jsonElement = gson.toJsonTree(entry.getValue());
			obj.add("columns", jsonElement);
			jsonArray.add(obj);
		}
	}
	jsonColumnsDtl = jsonArray.toString();
	response.setContentType(SyncConstants.CONTENT_TYPE_JSON);
	response.getWriter().println(jsonColumnsDtl);
	logger.info("Inside fetchColumnsForMultipleTables Completed");
}
 
开发者ID:gagoyal01,项目名称:mongodb-rdbms-sync,代码行数:36,代码来源:DatabaseDetailsController.java

示例7: getBedMetadataForMap

import com.google.gson.JsonArray; //导入方法依赖的package包/类
/**
 * Form a JSON to pass to the client to render in the Google Maps Bed Metadata Map
 *
 * This returns an array with an entry for each gardenLocation
 * {gardenLocation : string, likes : number, dislikes : number, comments : number}
 * @param plantController
 * @param uploadID
 * @return
 */
public String getBedMetadataForMap(PlantController plantController, String uploadID) {
    // Count Flower likes
    // Count flower dislikes
    // Count flower comments

    try {


        String[] bedNames = plantController.getGardenLocations(uploadID);
        JsonArray out = new JsonArray();

        for (int i = 0; i < bedNames.length; i++) {
            int likes = 0;
            int dislikes = 0;
            int comments = 0;
            JsonObject bed = new JsonObject();
            Document filter = new Document();
            filter.append("uploadId", uploadID);
            filter.append("gardenLocation", bedNames[i]);

            FindIterable<Document> iter = plantCollection.find(filter);
            for (Document plant : iter) {
                long[] feedback = plantController.getPlantFeedbackByPlantId(plant.getString("id"), uploadID);

                likes += feedback[PlantController.PLANT_FEEDBACK_LIKES];
                dislikes += feedback[PlantController.PLANT_FEEDBACK_DISLIKES];
                comments += feedback[PlantController.PLANT_FEEDBACK_COMMENTS];
            }
            bed.addProperty("gardenLocation", bedNames[i]);
            bed.addProperty("likes", likes);
            bed.addProperty("dislikes", dislikes);
            bed.addProperty("comments", comments);//TODO: could be refactored to include pageViews
            out.add(bed);
        }

        return out.toString();
    }
    catch(Exception e)
    {
        e.printStackTrace();
        throw e;
    }
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-revolverenguardia-1,代码行数:53,代码来源:GardenCharts.java

示例8: getBedMetadataForBubbleMap

import com.google.gson.JsonArray; //导入方法依赖的package包/类
/**
 * Form a JSON to pass to the client to render in the BubbleMap google chart.
 *
 * This returns an array with an entry for each gardenLocation
 * {gardenLocation : string, likes : number, pageViews : number}
 * @param plantController in order to getGardenLocations and PlantFeedback to count likes
 * @param bedController in order to get Page views for a bed
 * @param uploadID
 * @return
 */
public String getBedMetadataForBubbleMap(PlantController plantController, BedController bedController, String uploadID) {
    // Count Flower likes
    // Count flower dislikes
    // Count flower comments

    try {
        int pageViews;

        String[] bedNames = plantController.getGardenLocations(uploadID);
        JsonArray out = new JsonArray();

        for (int i = 0; i < bedNames.length; i++) {
            int likes = 0;
            JsonObject bed = new JsonObject();
            Document filter = new Document();
            filter.append("uploadId", uploadID);
            filter.append("gardenLocation", bedNames[i]);

            FindIterable<Document> iter = plantCollection.find(filter);
            for (Document plant : iter) {
                long[] feedback = plantController.getPlantFeedbackByPlantId(plant.getString("id"), uploadID);
                likes += feedback[PlantController.PLANT_FEEDBACK_LIKES];
            }

            pageViews = bedController.getPageViews(bedNames[i], uploadID);

            bed.addProperty("gardenLocation", bedNames[i]);
            bed.addProperty("likes", likes);
            bed.addProperty("pageViews", pageViews);
            out.add(bed);
        }

        return out.toString();
    }
    catch(Exception e)
    {
        e.printStackTrace();
        throw e;
    }
}
 
开发者ID:UMM-CSci-3601-S17,项目名称:digital-display-garden-iteration-4-revolverenguardia-1,代码行数:51,代码来源:GardenCharts.java


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