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


Java JSONObject.toString方法代码示例

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


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

示例1: respStacks

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
private static String respStacks() {
    try {
        JSONObject response = new JSONObject();
        JSONObject state = new JSONObject();
        state.put("label", "OK");
        state.put("id", "OK");
        response.put("state", state);
        response.put("id", "1234");
        response.put("stack", "1234");
        response.put("name", "Appliance1");
        response.put("projectUri",
                "http://test.com/cloud/api/projects/54346");
        JSONObject stack = new JSONObject();
        stack.put("id", "idValue");
        response.put("stack", stack);
        return response.toString();
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:21,代码来源:MockURLStreamHandler.java

示例2: getJSON

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
public String getJSON() throws JSONException {
	JSONObject json = new JSONObject();
	JSONArray nodes = new JSONArray();
	json.put("nodes", nodes);
	List<Integer> operatorIDs = new ArrayList<Integer>(streamGraph.getVertexIDs());
	Collections.sort(operatorIDs, new Comparator<Integer>() {
		@Override
		public int compare(Integer o1, Integer o2) {
			// put sinks at the back
			if (streamGraph.getSinkIDs().contains(o1)) {
				return 1;
			} else if (streamGraph.getSinkIDs().contains(o2)) {
				return -1;
			} else {
				return o1 - o2;
			}
		}
	});
	visit(nodes, operatorIDs, new HashMap<Integer, Integer>());
	return json.toString();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:JSONGenerator.java

示例3: respFlavor

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
/**
 * @param string
 * @return
 */
public static String respFlavor(int id, String flavorName) {
    try {
        JSONObject response = new JSONObject();
        JSONObject flavor = new JSONObject();
        flavor.put("id", id);
        flavor.put("name", flavorName);

        response.put("flavor", flavor);
        return response.toString();
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:MockURLStreamHandler.java

示例4: repServers

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
/**
 * @return
 */
private static String repServers(List<String> serverNames) {
    try {
        JSONObject response = new JSONObject();
        JSONArray servers = new JSONArray();
        for (int i = 0; i < serverNames.size(); i++) {
            JSONObject server = new JSONObject();
            JSONArray links = new JSONArray();
            JSONObject linkSelf = new JSONObject();
            JSONObject linkBookmark = new JSONObject();
            String instanceId = Integer.toString(i) + "-Instance-"
                    + serverNames.get(i);
            server.put("id", instanceId);
            linkSelf.put("href",
                    "http://novaendpoint/v2/servers/" + instanceId);
            linkSelf.put("rel", "self");
            links.put(linkSelf);
            linkBookmark.put("href",
                    "http://novaendpoint/servers/" + instanceId);
            linkBookmark.put("rel", "self");
            links.put(linkBookmark);
            server.put("links", links);
            server.put("name", serverNames.get(i));
            servers.put(server);
        }
        response.put("servers", servers);
        return response.toString();
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:34,代码来源:MockURLStreamHandler.java

示例5: respStacksInstanceName

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
public static String respStacksInstanceName(StackStatus status,
        boolean withStatusReason, String... stackStatusReason) {
    String reason;
    if (stackStatusReason == null || stackStatusReason.length == 0) {
        reason = "SSR";
    } else {
        reason = Arrays.toString(stackStatusReason);
    }
    try {
        JSONObject response = new JSONObject();
        JSONObject stack = new JSONObject();
        response.put("stack", stack);
        stack.put("stack_name", "SN");
        stack.put("id", "ID");
        stack.put("stack_status",
                status == null ? "bullshit" : status.name());
        if (withStatusReason) {
            stack.put("stack_status_reason", reason);
        }
        JSONArray outputs = new JSONArray();
        JSONObject output = new JSONObject();
        output.put("output_key", "OK");
        output.put("output_value", "OV");
        outputs.put(output);
        stack.put("outputs", outputs);
        return response.toString();
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:31,代码来源:MockURLStreamHandler.java

示例6: respStacksResources

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
public static String respStacksResources(List<String> serverNames,
        String resourceType) {
    try {
        JSONObject response = new JSONObject();
        JSONArray resources = new JSONArray();
        response.put("resources", resources);

        JSONObject volume = new JSONObject();
        volume.put("resource_name", "sys-vol");
        volume.put("physical_resource_id", "12345");
        volume.put("resource_type", "OS::Cinder::Volume");
        resources.put(volume);

        for (int i = 0; i < serverNames.size(); i++) {
            JSONObject server = new JSONObject();
            server.put("resource_name", serverNames.get(i));
            server.put("physical_resource_id", Integer.toString(i)
                    + "-Instance-" + serverNames.get(i));
            server.put("resource_type", resourceType);
            resources.put(server);
        }

        return response.toString();
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:28,代码来源:MockURLStreamHandler.java

示例7: respServer

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
public static String respServer(String serverName, String serverId) {
    try {
        JSONObject response = new JSONObject();
        JSONObject server = new JSONObject();
        response.put("server", server);
        server.put("name", serverName);
        server.put("id", serverId);

        return response.toString();
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:14,代码来源:MockURLStreamHandler.java

示例8: respServerDetail

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
public static String respServerDetail(String serverName, String serverId,
        ServerStatus status, String tenant_id) {
    try {
        JSONObject response = new JSONObject();
        JSONObject server = new JSONObject();
        response.put("server", server);
        server.put("name", serverName);
        server.put("id", serverId);
        server.put("status", status);
        server.put("tenant_id", tenant_id);
        server.put("accessIPv4", "192.0.2.0");
        JSONObject flavor = new JSONObject();
        flavor.put("id", 1);
        server.put("flavor", flavor);
        JSONObject addresses = new JSONObject();
        JSONArray networkDetail = new JSONArray();
        JSONObject fixedNetwork = new JSONObject();
        JSONObject floatingNetwork = new JSONObject();
        fixedNetwork.put("OS-EXT-IPS-MAC:mac_addr", "fa:16:3e:e5:b7:f8");
        fixedNetwork.put("version", "4");
        fixedNetwork.put("addr", "192.168.0.4");
        fixedNetwork.put("OS-EXT-IPS:type", "fixed");
        floatingNetwork.put("OS-EXT-IPS-MAC:mac_addr", "fa:16:3e:e5:b7:f8");
        floatingNetwork.put("version", "4");
        floatingNetwork.put("addr", "133.162.161.216");
        floatingNetwork.put("OS-EXT-IPS:type", "floating");
        networkDetail.put(fixedNetwork);
        networkDetail.put(floatingNetwork);
        addresses.put(serverName + "-network", networkDetail);
        server.put("addresses", addresses);

        return response.toString();
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:37,代码来源:MockURLStreamHandler.java

示例9: respTokens

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
public static String respTokens(boolean addPublicURL,
        boolean addPublicURLNova, boolean https) {
    try {
        JSONObject response = new JSONObject();
        JSONObject token = new JSONObject();
        JSONArray serviceCatalog = new JSONArray();

        JSONObject endpointsHeat = new JSONObject();
        JSONArray endpointsListHeat = new JSONArray();
        String httpMethod = https == true ? "https://" : "http://";
        endpointsHeat.put("endpoints", endpointsListHeat);
        if (addPublicURL) {
            JSONObject publicUrl = new JSONObject();
            publicUrl.put("name", KeystoneClient.TYPE_HEAT);
            publicUrl.put("url", httpMethod + "heatendpoint/");
            publicUrl.put("interface", "public");
            endpointsListHeat.put(publicUrl);
        }

        endpointsHeat.put("type", KeystoneClient.TYPE_HEAT);
        serviceCatalog.put(endpointsHeat);

        JSONObject endpointsNova = new JSONObject();

        JSONArray endpointsListNova = new JSONArray();
        endpointsNova.put("endpoints", endpointsListNova);
        if (addPublicURLNova) {
            JSONObject publicUrlNova = new JSONObject();
            publicUrlNova.put("name", KeystoneClient.TYPE_NOVA);
            publicUrlNova.put("url", httpMethod + "novaendpoint/");
            publicUrlNova.put("interface", "public");
            endpointsListNova.put(publicUrlNova);
        }

        endpointsNova.put("type", KeystoneClient.TYPE_NOVA);
        serviceCatalog.put(endpointsNova);

        token.put("id", "authId");
        token.put("catalog", serviceCatalog);

        response.put("token", token);

        return response.toString();
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:48,代码来源:MockURLStreamHandler.java

示例10: respServerActions

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
public static String respServerActions() {
    JSONObject response = new JSONObject();
    return response.toString();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:5,代码来源:MockURLStreamHandler.java

示例11: respStacksInstance4sIdActions

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
private static String respStacksInstance4sIdActions() {
    JSONObject response = new JSONObject();
    return response.toString();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:5,代码来源:MockURLStreamHandler.java

示例12: respStackDeleted

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
public static String respStackDeleted() {
    JSONObject response = new JSONObject();
    return response.toString();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:5,代码来源:MockURLStreamHandler.java

示例13: map

import org.apache.sling.commons.json.JSONObject; //导入方法依赖的package包/类
/**
 * @see org.apache.flink.api.common.functions.MapFunction#map(java.lang.Object)
 */
public String map(JSONObject json) throws Exception {		
	if(json == null)
		return "{}";
	return json.toString();
}
 
开发者ID:ottogroup,项目名称:flink-operator-library,代码行数:9,代码来源:JsonObjectToString.java


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