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


Java JSONObject.getString方法代码示例

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


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

示例1: dispatchEvent

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public void dispatchEvent(JSONObject json, int sequence) {
    String id = json.getString("id");
    boolean unavailable = json.has("unavailable") && json.getBoolean("unavailable");

    Guild guild = (Guild) identity.getGuild(id);
    if (guild == null) {
        logger.log(LogLevel.FETAL, "[UNKNOWN GUILD] [GUILD_DELETE_EVENT]");
        return;
    }

    if (unavailable) {
        guild.setUnavailable(true);
        dispatchEvent(new GuildUnavailableEvent(identity, sequence, guild));
    } else {
        identity.removeGuild(id);
        dispatchEvent(new GuildDeleteEvent(identity, sequence, guild, OffsetDateTime.now()));
    }
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:20,代码来源:GuildDeleteEventHandler.java

示例2: setupContacts

import org.json.JSONObject; //导入方法依赖的package包/类
public void setupContacts(JSONObject key) {
    JSONArray array = key.getJSONArray("private_channels");
    for (int i = 0; i < array.length(); i++) {
        JSONObject item = array.getJSONObject(i);
        JSONObject contact = item.getJSONObject("recipient");

        String id = contact.getString("id");

        if (item.getString("id").equals(api.getSelfInfo().getId()))
            api.setAs(contact.getString("id"));

        UserImpl userImpl = new UserImpl(contact.getString("username"), id, item.getString("id"), api);
        userImpl.setAvatar(contact.isNull("avatar") ? "" : "https://cdn.discordapp.com/avatars/" + id + "/" +
                contact.getString("avatar") + ".jpg");
        userImpl.setAvatarId(contact.isNull("avatar") ? "" : userImpl.getId());

        api.getAvailableDms().add(userImpl);
    }
}
 
开发者ID:discord-java,项目名称:discord.jar,代码行数:20,代码来源:ReadyPoll.java

示例3: parseStatus

import org.json.JSONObject; //导入方法依赖的package包/类
private void parseStatus(String result){
	try {
		JSONObject json = new JSONObject(result);
		String status = json.getString("STATUS");
		rejected = json.getString("REJECTNO");
		if(status.equalsIgnoreCase("SUCCESS")){
			setResult(1001);
			sendNotification();
		}else if(status.equalsIgnoreCase("Already exist")){
			comman.alertDialog(AddNewMembers.this,getString(R.string.group_already_exist_head),getString(R.string.group_already_exist));
			return;
		}else{
			comman.alertDialog(AddNewMembers.this,getString(R.string.group_already_exist_head),getString(R.string.group_already_exist_error));
			return;
		}
	} catch (Exception e) {
		// TODO: handle exception
	}
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:20,代码来源:AddNewMembers.java

示例4: UIEvent

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * Constructs a UIEvent from the JSON serialized representation.
 *
 * @param json The serialized UIEvent.
 * @throws JSONException
 */
public UIEvent(JSONObject json) throws JSONException {
    super(TYPE_UI, json);
    String element = json.getString(JSON_ELEMENT);
    try {
        mUiElement = validateUiElement(element);
    } catch (IllegalArgumentException e) {
        throw new JSONException("Invalid UI element: " + element);
    }
    if (mUiElement != ELEMENT_CATEGORY && TextUtils.isEmpty(mBlockId)) {
        throw new JSONException("UI element " + mUiElement + " requires " + JSON_BLOCK_ID);
    }
    this.mOldValue = json.optString(JSON_OLD_VALUE);  // Rarely used.
    this.mNewValue = json.optString(JSON_NEW_VALUE);
    if (mUiElement != ELEMENT_CATEGORY && mUiElement != ELEMENT_CLICK
            && TextUtils.isEmpty(mNewValue)) {
        throw new JSONException("UI element " + mUiElement + " requires " + JSON_NEW_VALUE);
    }
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:25,代码来源:BlocklyEvent.java

示例5: buttonClicked

import org.json.JSONObject; //导入方法依赖的package包/类
@JavascriptInterface
public void buttonClicked(String jsonString) {
    try {
        final JSONObject json = new JSONObject(jsonString);
        final JSONObject result = new JSONObject().put("id", json.getString("id"));

        if (json.has("buttonId")) {
            final String buttonId = json.getString("buttonId");
            coreSdkHandler.post(new Runnable() {
                @Override
                public void run() {
                    repository.add(new ButtonClicked(campaignId, buttonId, System.currentTimeMillis()));
                }
            });
            result.put("success", true);
        } else {
            result.put("success", false)
                    .put("error", "Missing buttonId!");
        }
        sendResult(result);
    } catch (JSONException je) {
        EMSLogger.log(MobileEngageTopic.IN_APP_MESSAGE, "Exception occurred, exception: %s json: %s", je, jsonString);
    }
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:25,代码来源:IamJsBridge.java

示例6: parseAttachmentsJSON

import org.json.JSONObject; //导入方法依赖的package包/类
private static List<Attachment> parseAttachmentsJSON(JSONObject attachmentsJSONObject) throws JSONException {
    List<Attachment> attachmentList = new ArrayList<>();

    JSONArray listJSONArray = attachmentsJSONObject.getJSONArray("List");
    int jsonArraySize = attachmentsJSONObject.getInt("Size");

    for (int index = 0; index < jsonArraySize; index++) {
        JSONObject listJSONObject = listJSONArray.getJSONObject(index);
        String name = listJSONObject.getString("Name");
        String link = listJSONObject.getString("Link");

        attachmentList.add(new Attachment(name, link));
    }

    return attachmentList;
}
 
开发者ID:DSM-DMS,项目名称:DMS,代码行数:17,代码来源:JSONParser.java

示例7: requestDataFiles

import org.json.JSONObject; //导入方法依赖的package包/类
private void requestDataFiles(JSONObject objFormat) throws JSONException {
    // objFormat has the list of data files for the OBJ format (OBJ file, MTL file, textures).
    // We will use a AsyncFileDownloader to download all those files.
    mFileDownloader = new AsyncFileDownloader();

    // The "root file" is the OBJ.
    JSONObject rootFile = objFormat.getJSONObject("root");
    mFileDownloader.add(rootFile.getString("relativePath"), rootFile.getString("url"));

    // The "resource files" are the MTL file and textures.
    JSONArray resources = objFormat.getJSONArray("resources");
    for (int i = 0; i < resources.length(); i++) {
        JSONObject resourceFile = resources.getJSONObject(i);
        String path = resourceFile.getString("relativePath");
        String url = resourceFile.getString("url");
        // For this example, we only care about OBJ and PNG files.
        if (path.toLowerCase().endsWith(".obj") || path.toLowerCase().endsWith(".png")) {
            mFileDownloader.add(path, url);
        }
    }

    // Now start downloading the data files. When this is done, the callback will call
    // processDataFiles().
    Log.d(TAG, "Starting to download data files, # files: " + mFileDownloader.getEntryCount());
    mFileDownloader.start(mBackgroundThreadHandler, new AsyncFileDownloader.CompletionListener() {
        @Override
        public void onPolyDownloadFinished(AsyncFileDownloader downloader) {
            if (downloader.isError()) {
                Log.e(TAG, "Failed to download data files for asset.");
                return;
            }
            // Signal to the GL thread that download is complete, so it can go ahead and
            // import the model.
            Log.d(TAG, "Download complete, ready to import model.");
            mReadyToImport = true;
        }
    });
}
 
开发者ID:googlevr,项目名称:poly-sample-android,代码行数:39,代码来源:HelloArActivity.java

示例8: getAccessToken

import org.json.JSONObject; //导入方法依赖的package包/类
private String getAccessToken() {
    String token = "";
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
    String token_string = sharedPreferences.getString("trakt_token", "");
    if(token_string.equals("")) return "";
    try {
        JSONObject json_token = new JSONObject(token_string);
        token = json_token.getString("access_token");
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return token;
}
 
开发者ID:ad-on-is,项目名称:chilly,代码行数:15,代码来源:Chilly.java

示例9: testUpdateWithEmptyValues

import org.json.JSONObject; //导入方法依赖的package包/类
public void testUpdateWithEmptyValues() throws Exception
{
    JSONObject item = createPost("test", "test", null, false, 200);
    String name = item.getString("name");
    assertEquals(false, item.getBoolean("isUpdated"));
    
    item = updatePost(item.getString("name"), null, null, null, false, 200);
    assertEquals("", item.getString("title"));
    assertEquals("", item.getString("content"));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:11,代码来源:BlogServiceTest.java

示例10: getOldFileVersionStr

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 *
 * @param file 文件路径
 * @param versionKey 下载版本文件的url
 * @return 旧的版本文件中file的版本号 是文件的md5值
 * @return 新版本文件中file的版本号 是文件的crc32值
 * @throws JSONException
 */
private String getOldFileVersionStr(String file, String versionKey) throws JSONException {
    String v ="";

    String versionTxt = cookie.getCookie(versionKey);//得到sp中保存的cookievalue实体中的版本文件 json字符串,和上次版本的版本文件比较,文件的版本号
    //如果本地本来就没有下载version.txt文件,那么return "",即下载本次的版本文件
    if (versionTxt.equals("")){
        return "";
    }

    JSONObject json = new JSONObject(versionTxt);
    json = json.getJSONObject("update");
    Iterator<String> it = json.keys();

    boolean lock = true;
    while (it.hasNext()) {
        String str = (String) it.next();
        JSONArray array = json.getJSONArray(str);
        lock = true;
        for (int i = 0; i < array.length(); i++) {
            JSONObject obj = array.getJSONObject(i);
            v = obj.getString("ver");//是文件的crc32值,是String类型
            String p = obj.getString("file");

            if (p.equals(file)) {//如果旧的版本文件中file文件名称和新的版本文件中file文件名称相同
                lock = false;
                break;
            }
        }

        if (!lock) {
            break;
        }
    }
    if (lock) {
        v = "0";
    }
    return v;
}
 
开发者ID:AlpacaNotSheep,项目名称:hybrid,代码行数:47,代码来源:SyncVersion.java

示例11: parseJson

import org.json.JSONObject; //导入方法依赖的package包/类
private void parseJson(String result){
	try {
		JSONObject json = new JSONObject(result);
		StatusId = json.getString("STATUS");
		shared.saveSharedData("State", StatusId);
		String mOTP = json.getString("OTP");
		shared.saveSharedData("mOTP", mOTP);
		if(StatusId.equalsIgnoreCase("0")){
			//If phone number not exist.fill all the parameter manually
			 //senOTPJson("+"+countryPrefix+edtMobile.getText().toString().trim());
			sendComposedSms(countryPrefix+edtMobile.getText().toString().trim(), mOTP+" "+getString(R.string.verify_otp));
			/*Intent i = new Intent(SignIn.this, VerifyOTP.class);
			i.putExtra("State", StatusId);
			i.putExtra("MobileNum", edtMobile.getText().toString().trim());
			i.putExtra("CountryCode", countryPrefix);
			i.putExtra("CountryName", countryName);
			startActivity(i);*/
			//SignIn.this.finish();
		}else if(StatusId.equalsIgnoreCase("2")){
			//If user already registered login  & enter OTP
			sendComposedSms(countryPrefix+edtMobile.getText().toString().trim(), mOTP+" "+getString(R.string.verify_otp));
			/*Intent i = new Intent(SignIn.this, VerifyOTP.class);
			i.putExtra("State", StatusId);
			i.putExtra("MobileNum", edtMobile.getText().toString().trim());
			i.putExtra("CountryCode", countryPrefix);
			i.putExtra("CountryName", countryName);
			startActivity(i);
			SignIn.this.finish();*/
		}
	} catch (Exception e) {
		// TODO: handle exception
	}
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:34,代码来源:SignIn.java

示例12: handleErrorResponse

import org.json.JSONObject; //导入方法依赖的package包/类
private void handleErrorResponse(JSONObject response) {
    if (response.has("code")) {
        if (!(response.get("code") instanceof Integer)) return;
        ErrorResponse errorResponse = ErrorResponse.getByKey(response.getInt("code"));
        if (errorResponse != ErrorResponse.UNKNOWN) {
            throw new ErrorResponseException(errorResponse);
        } else {
            throw new ErrorResponseException(response.getInt("code"), response.getString("message"));
        }
    }
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:12,代码来源:Requester.java

示例13: getObjectFromJsonObject

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * Create a concrete object from the JSONObject received.
 *
 * The class to instanciate is deduced from the value of the "type" field of
 * JSONObject.
 * @param jsonData
 * @return the object newly created
 */
private JSONable getObjectFromJsonObject(final JSONObject jsonData) {
    JSONable result = null;
    switch (jsonData.getString("type")) {

        case "Block":
            result = new Block(jsonData);
            break;

        case "BlockChain":
            result = new BlockChain(jsonData);
            break;

        case "Address":
            result = new Address(jsonData);
            break;

        case "Transaction":
            result = new Transaction(jsonData);
            break;

        case "TestStr":
            result = new TestStrJSONable(jsonData);
            break;

        case "Message":
            result = new Message(jsonData);
            break;
    }

    return result;
}
 
开发者ID:StanIsAdmin,项目名称:CrashCoin,代码行数:40,代码来源:AbstractConnection.java

示例14: extractBusStopsFromJson

import org.json.JSONObject; //导入方法依赖的package包/类
private List<BusStop> extractBusStopsFromJson(String realTimeTransitInformationJson) {

        // If the JSON is empty, return null and exit early.
        if (TextUtils.isEmpty(realTimeTransitInformationJson)) {
            return null;
        }

        List<BusStop> busStopList = new ArrayList<>();

        try {

            JSONArray busStopArray = new JSONArray(realTimeTransitInformationJson);

            for (int i = 0; i < busStopArray.length(); i++) {
                JSONObject currentBusStop = busStopArray.getJSONObject(i);

                String name = null;
                if (currentBusStop.has("Name")) {
                    name = currentBusStop.getString("Name");
                }

                String routes = null;
                if (currentBusStop.has("Routes")) {
                    routes = currentBusStop.getString("Routes");
                }

                String stopNumber = null;
                if (currentBusStop.has("StopNo")) {
                    stopNumber = currentBusStop.getString("StopNo");
                }

                String atStreet = null;
                if (currentBusStop.has("AtStreet")) {
                    atStreet = currentBusStop.getString("AtStreet");
                }

                String onStreet = null;
                if (currentBusStop.has("OnStreet")) {
                    onStreet = currentBusStop.getString("OnStreet");
                }


                busStopList.add(new BusStop(name, routes, stopNumber, atStreet, onStreet));
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return busStopList;
    }
 
开发者ID:joshvocal,项目名称:TransLinkMe-App,代码行数:52,代码来源:BusStopRadiusLoader.java

示例15: toJavaCandidate

import org.json.JSONObject; //导入方法依赖的package包/类
IceCandidate toJavaCandidate(JSONObject json) throws JSONException {
  return new IceCandidate(
      json.getString("id"), json.getInt("label"), json.getString("candidate"));
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:5,代码来源:WebSocketRTCClient.java


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