本文整理汇总了Java中us.monoid.web.Resty.json方法的典型用法代码示例。如果您正苦于以下问题:Java Resty.json方法的具体用法?Java Resty.json怎么用?Java Resty.json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类us.monoid.web.Resty
的用法示例。
在下文中一共展示了Resty.json方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJSON
import us.monoid.web.Resty; //导入方法依赖的package包/类
/**
* @param url
* @return Returns the JSON
*/
private String getJSON(String url){
JSONResource res = null;
JSONObject obj = null;
Resty resty = new Resty();
try {
res = resty.json(url);
obj = res.toObject();
} catch (IOException | JSONException e) {
// TODO: not my favorite way but does the trick
// e.printStackTrace();
return getJSON(url);
}
return obj.toString();
}
示例2: getJSON
import us.monoid.web.Resty; //导入方法依赖的package包/类
/**
* @param url
* @return Returns the JSON as JSON Resource
*/
private JSONResource getJSON(String url) throws uQasarException{
JSONResource res = null;
Resty resty = new Resty();
// Connection counter +1
counter +=1;
// Replaces spaces in URL with char %20
url = url.replaceAll(" ", "%20");
try {
res = resty.json(url);
} catch (IOException e) {
// Check if the limit of trials has been reached
if(counter<counterLimit){
return getJSON(url);} else
throw new uQasarException("Cubes Server is not availabe at this moument, error to connect with " +url);
}
// Reset the connection counter to 0
counter = 0;
return res;
}
示例3: login
import us.monoid.web.Resty; //导入方法依赖的package包/类
public void login() throws IOException, LoginException {
Resty r = new Resty();
JSONResource authTickets = r.json(baseURL + "access/ticket",
form("username=" + username + "@" + realm + "&password=" + password));
try {
authTicket = authTickets.get("data.ticket").toString();
csrfPreventionToken = authTickets.get("data.CSRFPreventionToken").toString();
authTicketIssuedTimestamp = new Date();
} catch (Exception e) {
throw new LoginException("Failed reading JSON response");
}
}
示例4: rollbackQemuMachineSnapshot
import us.monoid.web.Resty; //导入方法依赖的package包/类
public String rollbackQemuMachineSnapshot(String node, Integer vmid, String snapshotName)
throws IOException, LoginException, JSONException {
Resty r = authedClient();
String resource = "nodes/" + node + "/qemu/" + vmid.toString() + "/snapshot/" + snapshotName + "/rollback";
JSONResource response = r.json(baseURL + resource, form(""));
return response.toObject().getString("data");
}
示例5: startQemuMachine
import us.monoid.web.Resty; //导入方法依赖的package包/类
public String startQemuMachine(String node, Integer vmid) throws IOException, LoginException, JSONException {
Resty r = authedClient();
String resource = "nodes/" + node + "/qemu/" + vmid.toString() + "/status/start";
JSONResource response = r.json(baseURL + resource, form(""));
return response.toObject().getString("data");
}
示例6: stopQemuMachine
import us.monoid.web.Resty; //导入方法依赖的package包/类
public String stopQemuMachine(String node, Integer vmid) throws IOException, LoginException, JSONException {
Resty r = authedClient();
String resource = "nodes/" + node + "/qemu/" + vmid.toString() + "/status/stop";
JSONResource response = r.json(baseURL + resource, form(""));
return response.toObject().getString("data");
}