本文整理匯總了Java中com.eclipsesource.json.JsonObject.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonObject.getString方法的具體用法?Java JsonObject.getString怎麽用?Java JsonObject.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.eclipsesource.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.getString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fromId
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
/**
* Get strawpoll from its ID
* @param id ID to lookup
* @return Strawpoll Object
* @throws IOException Strawpoll.me is down or denied our API access
*/
public static StrawpollObject fromId(int id) throws IOException {
JsonValue jv = Util.jsonFromUrl(BASE_API + "/" + id);
JsonObject jo = jv.asObject();
String title = jo.getString("title", "title");
boolean multiVote = jo.getBoolean("multi", false);
JsonArray jOptions = jo.get("options").asArray();
String[] options = new String[jOptions.size()];
JsonArray jVotes = jo.get("votes").asArray();
int[] votes = new int[jVotes.size()];
for(int i = 0; i < options.length; i++) {
options[i] = jOptions.get(i).asString();
votes[i] = jVotes.get(i).asInt();
}
return new StrawpollObject(title, multiVote, options, votes);
}
示例2: Station
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public Station(JPTI jpti, JsonObject json){
this(jpti);
try{
name =json.getString(NAME,"駅名不明");
subName=json.getString(SUBNAME,"");
type=json.getInt(TYPE,0);
description = json.getString(DESCRIPTION, "");
lat=json.getString(LAT,"");
lon=json.getString(LON,"");
url=json.getString(URL,"");
wheelcharBoarding=json.getString(WHEELCHAIR,"");
JsonArray stopArray=json.get(STOP).asArray();
for(int i=0;i<stopArray.size();i++){
stops.add(jpti.getStop(stopArray.get(i).asInt()));
jpti.getStop(stopArray.get(i).asInt()).setStation(this);
}
}catch (Exception e){
e.printStackTrace();
}
}
示例3: Trip
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public Trip(JPTI jpti, JsonObject json){
this.jpti=jpti;
try{
route=jpti.getRoute(json.getInt(ROUTE,0));
this.traihType=jpti.getTrainType(json.getInt(CLASS,0));
blockID=json.getInt(BLOCK,0);
calender=jpti.calendarList.get(json.getInt(CALENDER,0));
number=json.getString(NUMBER,"");
name=json.getString(NAME,"");
direction=json.getInt(DIRECTION,0);
extraCalendarID=json.getInt(EXTRA_CALENDER,-1);
JsonArray timeArray=json.get(TIME).asArray();
for(int i=0;i<timeArray.size();i++){
Time time=newTime(timeArray.get(i).asObject());
timeList.put(time.getStation(),time);
}
}catch(Exception e){
e.printStackTrace();
}
}
示例4: isCompletedOperationSuccessful
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public synchronized boolean isCompletedOperationSuccessful(String opID)
throws WalletCallException, IOException, InterruptedException
{
JsonArray response = this.executeCommandAndGetJsonArray(
"z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
JsonObject jsonStatus = response.get(0).asObject();
String status = jsonStatus.getString("status", "ERROR");
System.out.println("Operation " + opID + " status is " + response + ".");
if (status.equalsIgnoreCase("success"))
{
return true;
} else if (status.equalsIgnoreCase("error") || status.equalsIgnoreCase("failed"))
{
return false;
} else
{
throw new WalletCallException("Unexpected final operation status response from wallet: " + response.toString());
}
}
示例5: isSendingOperationComplete
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public synchronized boolean isSendingOperationComplete(String opID)
throws WalletCallException, IOException, InterruptedException
{
JsonArray response = this.executeCommandAndGetJsonArray(
"z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
JsonObject jsonStatus = response.get(0).asObject();
String status = jsonStatus.getString("status", "ERROR");
Log.info("Operation " + opID + " status is " + response + ".");
if (status.equalsIgnoreCase("success") ||
status.equalsIgnoreCase("error") ||
status.equalsIgnoreCase("failed"))
{
return true;
} else if (status.equalsIgnoreCase("executing") || status.equalsIgnoreCase("queued"))
{
return false;
} else
{
throw new WalletCallException("Unexpected status response from wallet: " + response.toString());
}
}
示例6: isCompletedOperationSuccessful
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public synchronized boolean isCompletedOperationSuccessful(String opID)
throws WalletCallException, IOException, InterruptedException
{
JsonArray response = this.executeCommandAndGetJsonArray(
"z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
JsonObject jsonStatus = response.get(0).asObject();
String status = jsonStatus.getString("status", "ERROR");
Log.info("Operation " + opID + " status is " + response + ".");
if (status.equalsIgnoreCase("success"))
{
return true;
} else if (status.equalsIgnoreCase("error") || status.equalsIgnoreCase("failed"))
{
return false;
} else
{
throw new WalletCallException("Unexpected final operation status response from wallet: " + response.toString());
}
}
示例7: Service
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public Service(JPTI jpti, JsonObject json){
this(jpti);
try{
name=json.getString(NAME,"");
JsonArray routeArray=json.get(ROUTE).asArray();
for(int i=0;i<routeArray.size();i++){
route.put(jpti.routeList.get(routeArray.get(i).asObject().getInt(ROUTE_ID,0)),routeArray.get(i).asObject().getInt(DIRECTION,0));
}
stationWidth=json.getInt(STATION_WIDTH,7);
trainWidth=json.getInt(TRAIN_WIDTH,5);
startTime=json.getString(START_TIME,"300");
defaulyStationSpace=json.getInt(STATION_SPACING,60);
comment=json.getString(COMMENT,"");
diaTextColor=new Color(Long.decode(json.getString(DIA_TEXT_COLOR,"#000000")).intValue());
diaBackColor=new Color(Long.decode(json.getString(DIA_BACK_COLOR,"#ffffff")).intValue());
diaTrainColor=new Color(Long.decode(json.getString(DIA_TRAIN_COLOR,"#000000")).intValue());
diaAxisColor=new Color(Long.decode(json.getString(DIA_AXICS_COLOR,"#000000")).intValue());
JsonArray timeTableFontArray=json.get(TIMETABLE_FONT).asArray();
for(int i=0;i<timeTableFontArray.size();i++){
timeTableFont.add(new Font(timeTableFontArray.get(i).asObject()));
}
timeTableVFont=new Font(json.get(TIMETABLE_VFONT).asObject());
diaStationFont=new Font(json.get(DIA_STATION_FONT).asObject());
diaTimeFont=new Font(json.get(DIA_TIME_FONT).asObject());
diaTrainFont=new Font(json.get(DIA_TRAIN_FONT).asObject());
commentFont=new Font(json.get(COMMENT_FONT).asObject());
JsonArray trainArray=json.get(TRAIN).asArray();
for(int i=0;i<trainArray.size();i++){
trainList.add(new Train(jpti,this,trainArray.get(i).asObject()));
}
}catch(Exception e){
e.printStackTrace();
}
}
示例8: getOperationFinalErrorMessage
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public synchronized String getOperationFinalErrorMessage(String opID)
throws WalletCallException, IOException, InterruptedException
{
JsonArray response = this.executeCommandAndGetJsonArray(
"z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
JsonObject jsonStatus = response.get(0).asObject();
JsonObject jsonError = jsonStatus.get("error").asObject();
return jsonError.getString("message", "ERROR!");
}
示例9: getWalletZReceivedTransactions
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public synchronized String[][] getWalletZReceivedTransactions()
throws WalletCallException, IOException, InterruptedException
{
String[] zAddresses = this.getWalletZAddresses();
List<String[]> zReceivedTransactions = new ArrayList<String[]>();
for (String zAddress : zAddresses)
{
JsonArray jsonTransactions = executeCommandAndGetJsonArray(
"z_listreceivedbyaddress", wrapStringParameter(zAddress), "0");
for (int i = 0; i < jsonTransactions.size(); i++)
{
String[] currentTransaction = new String[7];
JsonObject trans = jsonTransactions.get(i).asObject();
String txID = trans.getString("txid", "ERROR!");
// Needs to be the same as in getWalletPublicTransactions()
// TODO: some day refactor to use object containers
currentTransaction[0] = "\u2605Z (Private)";
currentTransaction[1] = "receive";
currentTransaction[2] = this.getWalletTransactionConfirmations(txID);
currentTransaction[3] = trans.get("amount").toString();
currentTransaction[4] = this.getWalletTransactionTime(txID); // TODO: minimize sub-calls
currentTransaction[5] = zAddress;
currentTransaction[6] = trans.get("txid").toString();
zReceivedTransactions.add(currentTransaction);
}
}
return zReceivedTransactions.toArray(new String[0][]);
}
示例10: Calendar
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public Calendar(JPTI jpti, JsonObject json){
this(jpti);
try{
name=json.getString(NAME,"");
}catch(Exception e){
}
}
示例11: Train
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public Train(JPTI jpti, Service service, JsonObject json){
this.jpti=jpti;
this.service=service;
direct=json.getInt(DIRECT,0);
name=json.getString(NAME,"");
number=json.getString(NUMBER,"");
count=json.getString(COUNT,"");
text=json.getString(TEXT,"");
calendar=jpti.getCalendar(json.getInt(CALENDER,0));
JsonArray tripArray=json.get(TRIP).asArray();
for(int i=0;i<tripArray.size();i++){
tripList.add(jpti.getTrip(tripArray.get(i).asInt()));
}
}
示例12: addItemTool
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public static void addItemTool(JsonObject js) {
String id = js.getString("id", null);
if (id == null) {
throw new JsonException("No item id");
}
JItemTool item = new JItemTool(id);
JsonObject tool = js.get("tool").asObject();
addItemToolFor(tool, item);
JsonValue prop;
prop = js.get("texture");
if (prop != null) {
item.textureString = prop.asString();
} else {
item.textureString = id;
}
for (JsonObject.Member member : js) {
switch (member.getName()) {
case "id":
case "texture":
case "tool":
break;
default:
throw new JsonException("Unexpected block member \"" + member.getName() + "\"");
}
}
IDManager.register(item);
}
示例13: parseSingle
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
private ItemStackPlaceholder parseSingle(JsonObject p) {
String id = p.getString("id", null);
if (id == null) throw new JsonException("No itemstack id");
int count = p.getInt("count", 1);
int meta = p.getInt("meta", 0);
return new ItemStackPlaceholder(id, count, meta);
}
示例14: oauth
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
/**
* Perform an Oauth2 callback to the Discord servers with the token given by the user's approval
* @param token Token from user
* @param res Passed on response
* @throws ClientProtocolException Error in HTTP protocol
* @throws IOException Encoding exception or error in protocol
* @throws NoAPIKeyException No API keys set
*/
static void oauth(String token, Response res) throws ClientProtocolException, IOException, NoAPIKeyException {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost post = new HttpPost("https://discordapp.com/api/oauth2/token");
List<NameValuePair> nvp = new ArrayList<NameValuePair>();
nvp.add(new BasicNameValuePair("client_id", Bot.getInstance().getApiKeys().get("dashboardid")));
nvp.add(new BasicNameValuePair("client_secret", Bot.getInstance().getApiKeys().get("dashboardsecret")));
nvp.add(new BasicNameValuePair("grant_type", "authorization_code"));
nvp.add(new BasicNameValuePair("code", token));
post.setEntity(new UrlEncodedFormEntity(nvp));
String accessToken;
CloseableHttpResponse response = httpclient.execute(post);
try {
System.out.println(response.getStatusLine());
HttpEntity entity = response.getEntity();
JsonObject authJson;
try(BufferedReader buffer = new BufferedReader(new InputStreamReader(entity.getContent()))) {
authJson = Json.parse(buffer.lines().collect(Collectors.joining("\n"))).asObject();
}
accessToken = authJson.getString("access_token", "");
EntityUtils.consume(entity);
getGuilds(res, accessToken);
} finally {
response.close();
}
}
示例15: getWalletPublicTransactions
import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public synchronized String[][] getWalletPublicTransactions()
throws WalletCallException, IOException, InterruptedException
{
String notListed = "\u26D4";
OS_TYPE os = OSUtil.getOSType();
if (os == OS_TYPE.WINDOWS)
{
notListed = " \u25B6";
}
JsonArray jsonTransactions = executeCommandAndGetJsonArray(
"listtransactions", wrapStringParameter(""), "100");
String strTransactions[][] = new String[jsonTransactions.size()][];
for (int i = 0; i < jsonTransactions.size(); i++)
{
strTransactions[i] = new String[7];
JsonObject trans = jsonTransactions.get(i).asObject();
// Needs to be the same as in getWalletZReceivedTransactions()
// TODO: some day refactor to use object containers
strTransactions[i][0] = "\u2606T (Public)";
strTransactions[i][1] = trans.getString("category", "ERROR!");
strTransactions[i][2] = trans.get("confirmations").toString();
strTransactions[i][3] = trans.get("amount").toString();
strTransactions[i][4] = trans.get("time").toString();
strTransactions[i][5] = trans.getString("address", notListed + " (Z Address not listed by wallet!)");
strTransactions[i][6] = trans.get("txid").toString();
}
return strTransactions;
}