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


Java JSONArray.getString方法代码示例

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


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

示例1: isAtMeMsg

import org.json.JSONArray; //导入方法依赖的package包/类
public boolean isAtMeMsg(EMMessage message) {
    EaseUser user = EaseUserUtils.getUserInfo(message.getFrom());
    if (user != null) {
        try {
            JSONArray jsonArray = message.getJSONArrayAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG);

            for (int i = 0; i < jsonArray.length(); i++) {
                String username = jsonArray.getString(i);
                if (username.equals(EMClient.getInstance().getCurrentUser())) {
                    return true;
                }
            }
        } catch (Exception e) {
            //perhaps is a @ all message
            String atUsername = message.getStringAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, null);
            if (atUsername != null) {
                if (atUsername.toUpperCase().equals(EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL)) {
                    return true;
                }
            }
            return false;
        }

    }
    return false;
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:27,代码来源:EaseAtMessageHelper.java

示例2: parseResults

import org.json.JSONArray; //导入方法依赖的package包/类
@Override
protected void parseResults(@NonNull InputStream inputStream, @NonNull List<HistoryItem> results) throws Exception {
    String content = FileUtils.readStringFromStream(inputStream, "GBK");
    JSONArray respArray = new JSONArray(content);
    JSONArray jsonArray = respArray.getJSONArray(1);

    int counter = 0;
    for (int n = 0, size = jsonArray.length(); n < size; n++) {
        String suggestion = jsonArray.getString(n);
        results.add(new HistoryItem(mSearchSubtitle + " \"" + suggestion + '"',
            suggestion, R.drawable.ic_search));
        counter++;

        if (counter >= MAX_RESULTS) {
            break;
        }
    }
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:19,代码来源:BaiduSuggestionsModel.java

示例3: execute

import org.json.JSONArray; //导入方法依赖的package包/类
@Override
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
    if (action.equals("upload") || action.equals("download")) {
        String source = args.getString(0);
        String target = args.getString(1);

        if (action.equals("upload")) {
            upload(source, target, args, callbackContext);
        } else {
            download(source, target, args, callbackContext);
        }
        return true;
    } else if (action.equals("abort")) {
        String objectId = args.getString(0);
        abort(objectId);
        callbackContext.success();
        return true;
    }
    return false;
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:21,代码来源:FileTransfer.java

示例4: getActivityTypeTemplates

import org.json.JSONArray; //导入方法依赖的package包/类
protected Map<String, List<String>> getActivityTypeTemplates(String repoEndPoint, String ticket, String subPath) throws Exception
{
    StringBuffer sbUrl = new StringBuffer();
    sbUrl.append(repoEndPoint).append(URL_SERVICE_TEMPLATES).append(subPath).append("*").append("?format=json");
    
    String jsonArrayResult = null;
    try
    {
        jsonArrayResult = callWebScript(sbUrl.toString(), ticket);
    }
    catch (FileNotFoundException e)
    {
        return null;
    }
    
    List<String> allTemplateNames = new ArrayList<String>(10);
    
    if ((jsonArrayResult != null) && (jsonArrayResult.length() != 0))
    {
        JSONArray ja = new JSONArray(jsonArrayResult);
        for (int i = 0; i < ja.length(); i++)
        {
            String name = ja.getString(i);
            allTemplateNames.add(name);
        }
    }
    
    return getActivityTemplates(allTemplateNames);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:FeedTaskProcessor.java

示例5: sendMessage

import org.json.JSONArray; //导入方法依赖的package包/类
/**
 * @param message
 */
public void sendMessage(String message) {
    JSONArray array = new JSONArray(message);
    String command = array.getString(0);
    JSONArray commandData = array.getJSONArray(1);

    JSONObject response = new JSONObject();
    response.put("_command", command);
    response.put("_data", commandData);


    CallbackClient.getInstance(parentHost).sendWebsocketMessage(this.sessionId, response.toString());
}
 
开发者ID:mware-solutions,项目名称:sether,代码行数:16,代码来源:SpongeJsApi.java

示例6: acceptEvent

import org.json.JSONArray; //导入方法依赖的package包/类
public void acceptEvent(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
    final String eventId = args.getString(0);
    final String placeId = args.getString(1);

    Radar.acceptEvent(eventId, placeId);

    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
}
 
开发者ID:Corollarium,项目名称:cordova-plugin-radar,代码行数:9,代码来源:RadarCordovaPlugin.java

示例7: getStrings

import org.json.JSONArray; //导入方法依赖的package包/类
public String[] getStrings(String key) {
  String[] strings = null;
  try {
    if (json != null) {
      JSONArray array = json.getJSONArray(key);
      strings = new String[array.length()];
      for (int i = 0; i < array.length(); i++) {
        strings[i] = array.getString(i);
      }
    }
  } catch (JSONException e) {
    xLogger.warn("Invalid regex for key {0}; expected a JSONArray", key);
  }
  return strings;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:16,代码来源:SMSConfig.java

示例8: removeMimeType

import org.json.JSONArray; //导入方法依赖的package包/类
private void removeMimeType(JSONArray data, CallbackContext callbackContext) throws JSONException {
    String mimeType = "";
    try {
        mimeType = data.getString(0);
        /*boolean removed =*/ removeIntentFilter(mimeType);
        callbackContext.success();
    } catch (MalformedMimeTypeException e) {
        callbackContext.error("Invalid MIME Type " + mimeType);
    }
}
 
开发者ID:theGreatWhiteShark,项目名称:mensacard-hack,代码行数:11,代码来源:NfcPlugin.java

示例9: remove

import org.json.JSONArray; //导入方法依赖的package包/类
private void remove(JSONArray args) throws JSONException {
    final String contactId = args.getString(0);
    this.cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            if (contactAccessor.remove(contactId)) {
                callbackContext.success();
            } else {
                callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, UNKNOWN_ERROR));
            }
        }
    });
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:13,代码来源:ContactManager.java

示例10: initAction

import org.json.JSONArray; //导入方法依赖的package包/类
/**
 * Intilization action
 * Initializes IronSource
 */
private void initAction(JSONArray args, final CallbackContext callbackContext) throws JSONException {

    final String appKey = args.getString(0);
    final String providedUserId = args.getString(1);

    final IronSourceAdsPlugin self = this;

    // getting advertiser id should be done on a background thread
    AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {

        @Override
        protected String doInBackground(Void... params) {
            return IronSource.getAdvertiserId(self.cordova.getActivity());
        }

        @Override
        protected void onPostExecute(String advertisingId) {

            String userId = providedUserId;

            if (TextUtils.isEmpty(userId)) {
                userId = advertisingId;
            }

            if (TextUtils.isEmpty(userId)) {
                userId = FALLBACK_USER_ID;
            }

            // we're using an advertisingId as the 'userId'
            init(appKey, userId);
            callbackContext.success();

        }
    };

    task.execute();
}
 
开发者ID:charlesbodman,项目名称:cordova-plugin-ironsource-ads,代码行数:42,代码来源:IronSourceAdsPlugin.java

示例11: removeNetwork

import org.json.JSONArray; //导入方法依赖的package包/类
/**
 *    This method removes a network from the list of configured networks.
 *
 *    @param    callbackContext        A Cordova callback context
 *    @param    data                JSON Array, with [0] being SSID to remove
 *    @return    true if network removed, false if failed
 */
private boolean removeNetwork(CallbackContext callbackContext, JSONArray data) {
    Log.d(TAG, "WifiWizard: removeNetwork entered.");

    if(!validateData(data)) {
        callbackContext.error("WifiWizard: removeNetwork data invalid");
        Log.d(TAG, "WifiWizard: removeNetwork data invalid");
        return false;
    }

    // TODO: Verify the type of data!
    try {
        String ssidToDisconnect = data.getString(0);

        int networkIdToRemove = ssidToNetworkId(ssidToDisconnect);

        if (networkIdToRemove >= 0) {
            wifiManager.removeNetwork(networkIdToRemove);
            wifiManager.saveConfiguration();
            callbackContext.success("Network removed.");
            return true;
        }
        else {
            callbackContext.error("Network not found.");
            Log.d(TAG, "WifiWizard: Network not found, can't remove.");
            return false;
        }
    }
    catch (Exception e) {
        callbackContext.error(e.getMessage());
        Log.d(TAG, e.getMessage());
        return false;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:41,代码来源:WifiWizard.java

示例12: disconnectNetwork

import org.json.JSONArray; //导入方法依赖的package包/类
/**
 *    This method disconnects a network.
 *
 *    @param    callbackContext        A Cordova callback context
 *    @param    data                JSON Array, with [0] being SSID to connect
 *    @return    true if network disconnected, false if failed
 */
private boolean disconnectNetwork(CallbackContext callbackContext, JSONArray data) {
Log.d(TAG, "WifiWizard: disconnectNetwork entered.");
    if(!validateData(data)) {
        callbackContext.error("WifiWizard: disconnectNetwork invalid data");
        Log.d(TAG, "WifiWizard: disconnectNetwork invalid data");
        return false;
    }
    String ssidToDisconnect = "";
    // TODO: Verify type of data here!
    try {
        ssidToDisconnect = data.getString(0);
    }
    catch (Exception e) {
        callbackContext.error(e.getMessage());
        Log.d(TAG, e.getMessage());
        return false;
    }

    int networkIdToDisconnect = ssidToNetworkId(ssidToDisconnect);

    if (networkIdToDisconnect > 0) {
        wifiManager.disableNetwork(networkIdToDisconnect);
        callbackContext.success("Network " + ssidToDisconnect + " disconnected!");
        return true;
    }
    else {
        callbackContext.error("Network " + ssidToDisconnect + " not found!");
        Log.d(TAG, "WifiWizard: Network not found to disconnect.");
        return false;
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:39,代码来源:WifiWizard.java

示例13: setWifiEnabled

import org.json.JSONArray; //导入方法依赖的package包/类
/**
 *    This method enables or disables the wifi
 */
private boolean setWifiEnabled(CallbackContext callbackContext, JSONArray data) {
    if(!validateData(data)) {
        callbackContext.error("WifiWizard: disconnectNetwork invalid data");
        Log.d(TAG, "WifiWizard: disconnectNetwork invalid data");
        return false;
    }
    
    String status = "";
    
    try {
        status = data.getString(0);
    }
    catch (Exception e) {
        callbackContext.error(e.getMessage());
        Log.d(TAG, e.getMessage());
        return false;
    }
    
    if (wifiManager.setWifiEnabled(status.equals("true"))) {
        callbackContext.success();
        return true;
    } 
    else {
        callbackContext.error("Cannot enable wifi");
        return false;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:31,代码来源:WifiWizard.java

示例14: toStringArray

import org.json.JSONArray; //导入方法依赖的package包/类
public String[] toStringArray(JSONArray value) {
    String[] s = new String[value.length()];
    for (int i = 0; i < value.length(); i++) {
        s[i] = value.getString(i);
    }
    return s;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:JavaServer.java

示例15: parserScope

import org.json.JSONArray; //导入方法依赖的package包/类
private Bundle parserScope(String scope) {
    Exception e;
    if (TextUtils.isEmpty(scope)) {
        LOG.e(TAG, "[scope:" + scope + "] response is empty");
        return null;
    }
    if (scope.startsWith("[") && scope.endsWith("]")) {
        scope = scope.substring(1, scope.length() - 1);
    }
    Bundle bundle = null;
    try {
        Bundle bundle2 = new Bundle();
        try {
            JSONObject jo = new JSONObject(scope);
            JSONArray ja = jo.names();
            for (int i = 0; i < ja.length(); i++) {
                String name = ja.getString(i);
                KVUtils.put(bundle2, name, jo.getString(name));
            }
            bundle = bundle2;
        } catch (Exception e2) {
            e = e2;
            bundle = bundle2;
            LOG.e(TAG, "json parse failed(Exception)", e);
            LOG.d(TAG, "bundle : " + bundle.toString());
            return bundle;
        }
    } catch (Exception e3) {
        e = e3;
        LOG.e(TAG, "json parse failed(Exception)", e);
        LOG.d(TAG, "bundle : " + bundle.toString());
        return bundle;
    }
    LOG.d(TAG, "bundle : " + bundle.toString());
    return bundle;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:37,代码来源:OAuth2Activity.java


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