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


Java JSONException类代码示例

本文整理汇总了Java中org.json.JSONException的典型用法代码示例。如果您正苦于以下问题:Java JSONException类的具体用法?Java JSONException怎么用?Java JSONException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getArrayString

import org.json.JSONException; //导入依赖的package包/类
public static String[] getArrayString(JSONObject docObj, String name) {
	String[] list = null;
	if (docObj.has(name)) {
		JSONArray json;
		try {
			json = docObj.getJSONArray(name);
			int lenFeatures = json.length();
			list = new String[lenFeatures];
			for (int j = 0; j < lenFeatures; j++) {
				String f = json.getString(j);
				list[j] = f;
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}

	}
	return list;

}
 
开发者ID:NewCasino,项目名称:browser,代码行数:21,代码来源:JSONUtil.java

示例2: toJSON

import org.json.JSONException; //导入依赖的package包/类
public static JSONObject toJSON(View view) throws JSONException {
  UiThreadUtil.assertOnUiThread();

  JSONObject result = new JSONObject();
  result.put("n", view.getClass().getName());
  result.put("i", System.identityHashCode(view));
  Object tag = view.getTag();
  if (tag != null && tag instanceof String) {
    result.put("t", tag);
  }

  if (view instanceof ViewGroup) {
    ViewGroup viewGroup = (ViewGroup) view;
    if (viewGroup.getChildCount() > 0) {
      JSONArray children = new JSONArray();
      for (int i = 0; i < viewGroup.getChildCount(); i++) {
        children.put(i, toJSON(viewGroup.getChildAt(i)));
      }
      result.put("c", children);
    }
  }

  return result;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:25,代码来源:ViewHierarchyDumper.java

示例3: parseJson

import org.json.JSONException; //导入依赖的package包/类
public  ArrayList<ProblemData> parseJson() throws JSONException {
    ArrayList<ProblemData> data = new ArrayList<>();
    JSONObject jsonObject  = jsondata;
   JSONObject res = jsonObject.getJSONObject("result");
   JSONArray problems = res.getJSONArray("problems");
    JSONArray stats = res.getJSONArray("problemStatistics");
    for(int i=0; i< stats.length() && i<20;i++){
        JSONObject nxtprob = problems.getJSONObject(i);
        JSONObject probstat = stats.getJSONObject(i);
        int id  = nxtprob.getInt("contestId");
        String idx = nxtprob.getString("index");
        String name = nxtprob.getString("name");
        int solvecnt = probstat.getInt("solvedCount");
        ProblemData dat = new ProblemData(id,idx,name,solvecnt);
        data.add(dat);


    }

    return data;
}
 
开发者ID:mkfeuhrer,项目名称:CodeMania,代码行数:22,代码来源:parser.java

示例4: execute

import org.json.JSONException; //导入依赖的package包/类
/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false if not.
 */
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if ("getDeviceInfo".equals(action)) {
        JSONObject r = new JSONObject();
        r.put("uuid", Device.uuid);
        r.put("version", this.getOSVersion());
        r.put("platform", this.getPlatform());
        r.put("model", this.getModel());
        r.put("manufacturer", this.getManufacturer());
     r.put("isVirtual", this.isVirtual());
        r.put("serial", this.getSerialNumber());
        callbackContext.success(r);
    }
    else {
        return false;
    }
    return true;
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:26,代码来源:Device.java

示例5: sendGetVideoSeriseListRequest

import org.json.JSONException; //导入依赖的package包/类
/**
 * 
 * 3.6.1.获取视频系列
 * 
 * @Description<功能详细描述>
 * 
 * @param task
 * @param handler
 * @param requestType
 * @param maxId
 * @param pagesize
 * @return
 * @LastModifiedDate:2016年10月10日
 * @author wl
 * @EditHistory:<修改内容><修改人>
 */
public static NetTask sendGetVideoSeriseListRequest(NetTask task, Handler handler, int requestType, String maxId,
    String pagesize)
{
    
    JSONObject bodyVaule = new JSONObject();
    try
    {
        bodyVaule.put("maxId", maxId);
        bodyVaule.put("pageSize", pagesize);
    }
    catch (JSONException e)
    {
        e.printStackTrace();
    }
    JSONObject requestObj =
        NetRequestController.getPredefineObj("video", "VideoAdapter", "getVideoSeriseList", "general", bodyVaule);
    
    return NetRequestController.sendStrBaseServlet(task, handler, requestType, requestObj);
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:36,代码来源:VedioCenterSeviceImpl.java

示例6: getParent

import org.json.JSONException; //导入依赖的package包/类
/**
 * Look up the parent DirectoryEntry containing this Entry.
 * If this Entry is the root of its filesystem, its parent is itself.
 */
private JSONObject getParent(String baseURLstr) throws JSONException, IOException {
    try {
    	LocalFilesystemURL inputURL = LocalFilesystemURL.parse(baseURLstr);
    	Filesystem fs = this.filesystemForURL(inputURL);
    	if (fs == null) {
    		throw new MalformedURLException("No installed handlers for this URL");
    	}
    	return fs.getParentForLocalURL(inputURL);

    } catch (IllegalArgumentException e) {
        MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
        mue.initCause(e);
    	throw mue;
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:20,代码来源:FileUtils.java

示例7: getParsedOsData

import org.json.JSONException; //导入依赖的package包/类
private JSONObject getParsedOsData() {
    JSONObject osData = new JSONObject();

    try {
        //cpu
        osData.put("cpu", getCpuInfo().toJson());

        // vmstat
        osData.put("vmstat", getVmstatInfo().toJson());

        //meminfo
        osData.put("meminfo", getMemInfoResource().toJson());

        //battery
        // TODO 권한 필요
        //osData.put("battery", 10);
        osData.put("battery", getBatteryPercent());

        //network_usage
        osData.put("network_usage", getNetworkUsageInfo().toJson());
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return osData;
}
 
开发者ID:TeamThresh,项目名称:Lantern-sdk,代码行数:27,代码来源:ShallowDumpData.java

示例8: execute

import org.json.JSONException; //导入依赖的package包/类
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if (action.equals("hide")) {
        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                webView.postMessage("splashscreen", "hide");
            }
        });
    } else if (action.equals("show")) {
        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                webView.postMessage("splashscreen", "show");
            }
        });
    } else {
        return false;
    }

    callbackContext.success();
    return true;
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:22,代码来源:SplashScreen.java

示例9: sendAddCloudRequest

import org.json.JSONException; //导入依赖的package包/类
public static NetTask sendAddCloudRequest(NetTask task, Handler handler, int requestType, String content,
    long createTime)
{
    JSONObject bodyVaule = new JSONObject();
    try
    {
        bodyVaule.put("content", content);
        bodyVaule.put("createTime", "" + createTime);
    }
    catch (JSONException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    JSONObject requestObj =
        NetRequestController.getPredefineObj("cloudevent",
            "CloudEventAdapter",
            "addCloudEvent",
            "general",
            bodyVaule);
    
    return NetRequestController.sendStrBaseServlet(task, handler, requestType, requestObj);
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:24,代码来源:NotePadSeviceImpl.java

示例10: serviceResolved

import org.json.JSONException; //导入依赖的package包/类
@Override
public void serviceResolved(ServiceEvent service) {
	Log.i(TAG, "serviceResolved " + service);

	if (service.getInfo().getNiceTextString().contains(SMARTCONFIG_IDENTIFIER)){
		JSONObject deviceJSON = new JSONObject();
		try {
			deviceJSON.put("name", service.getName());
			deviceJSON.put("host", service.getInfo().getHostAddresses()[0]);
			deviceJSON.put("age", 0);
			Log.i(TAG, "Publishing device found to application,  name: " + service.getName());

			callback.onDeviceResolved(deviceJSON);
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:hoanglm4,项目名称:RxAndroidTBP,代码行数:19,代码来源:MDnsHelper.java

示例11: toJSONString

import org.json.JSONException; //导入依赖的package包/类
@Override
public void toJSONString(JSONStringer stringer) throws JSONException {
    for (Members element : QueryStatistics.Members.values()) {
        try {
            Field field = QueryStatistics.class.getDeclaredField(element.toString().toLowerCase());
            if (element == Members.PARAM_HISTOGRAMS) {
                stringer.key(element.name()).object();
                for (Integer idx : this.param_histograms.keySet()) {
                    stringer.key(idx.toString()).object();
                    this.param_histograms.get(idx).toJSON(stringer);
                    stringer.endObject();
                } // FOR
                stringer.endObject();

                // } else if (element == Members.PARAM_PROC_CORELATIONS) {

            } else {
                stringer.key(element.name()).value(field.get(this));
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            System.exit(1);
        }
    } // FOR
}
 
开发者ID:s-store,项目名称:s-store,代码行数:26,代码来源:QueryStatistics.java

示例12: getIdToken

import org.json.JSONException; //导入依赖的package包/类
private void getIdToken(final boolean forceRefresh, final CallbackContext callbackContext) throws JSONException {
    cordova.getThreadPool().execute(new Runnable() {
        @Override
        public void run() {
            FirebaseUser user = firebaseAuth.getCurrentUser();

            if (user == null) {
                callbackContext.error("User is not authorized");
            } else {
                user.getIdToken(forceRefresh)
                    .addOnCompleteListener(cordova.getActivity(), new OnCompleteListener<GetTokenResult>() {
                        @Override
                        public void onComplete(Task<GetTokenResult> task) {
                            if (task.isSuccessful()) {
                                callbackContext.success(task.getResult().getToken());
                            } else {
                                callbackContext.error(task.getException().getMessage());
                            }
                        }
                    });
            }
        }
    });
}
 
开发者ID:chemerisuk,项目名称:cordova-plugin-firebase-authentication,代码行数:25,代码来源:FirebaseAuthenticationPlugin.java

示例13: sendComfirmBookSchedule

import org.json.JSONException; //导入依赖的package包/类
/**
 * 
 * 确认预约日程
 * 
 * @Description<功能详细描述>
 * 
 * @param task
 * @param handler
 * @param requestType
 * @param id
 * @param status
 * @return
 * @LastModifiedDate:2016年11月22日
 * @author wl
 * @EditHistory:<修改内容><修改人>
 */
public static NetTask sendComfirmBookSchedule(NetTask task, Handler handler, int requestType, String id,
    String status)
{
    JSONObject requestObj = null;
    try
    {
        JSONObject bodyVaule = new JSONObject();
        bodyVaule.put("id", id);
        bodyVaule.put("status", status);
        requestObj =
            NetRequestController.getPredefineObj("schedule",
                "ScheduleAdapter",
                "comfirmBookSchedule",
                "general",
                bodyVaule);
        
    }
    catch (JSONException e)
    {
        e.printStackTrace();
    }
    
    return NetRequestController.sendStrBaseServlet(task, handler, requestType, requestObj);
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:41,代码来源:SchedueSeviceImpl.java

示例14: execute

import org.json.JSONException; //导入依赖的package包/类
@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
    boolean cmdProcessed = true;
    if (JSAction.INIT.equals(action)) {
        jsInit(callbackContext);
    } else if (JSAction.FETCH_UPDATE.equals(action)) {
        jsFetchUpdate(callbackContext, args);
    } else if (JSAction.INSTALL_UPDATE.equals(action)) {
        jsInstallUpdate(callbackContext);
    } else if (JSAction.CONFIGURE.equals(action)) {
        jsSetPluginOptions(args, callbackContext);
    } else if (JSAction.REQUEST_APP_UPDATE.equals(action)) {
        jsRequestAppUpdate(args, callbackContext);
    } else if (JSAction.IS_UPDATE_AVAILABLE_FOR_INSTALLATION.equals(action)) {
        jsIsUpdateAvailableForInstallation(callbackContext);
    } else if (JSAction.GET_VERSION_INFO.equals(action)) {
        jsGetVersionInfo(callbackContext);
    } else {
        cmdProcessed = false;
    }

    return cmdProcessed;
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:24,代码来源:HotCodePushPlugin.java

示例15: getListValue

import org.json.JSONException; //导入依赖的package包/类
/**
 * Return a list of strings with data from the field.
 * @param jobj object
 * @param name name
 * @param field field
 * @return list of strings
 * @throws JSONException
 */
public static List<String> getListValue(JSONObject jobj, String name, String field)
        throws JSONException {

    if (jobj.isNull(name)) {
        return Collections.emptyList();
    } else {
        JSONArray jArray = jobj.getJSONArray(name);
        List<String> results = new ArrayList<>(jArray.length());
        JSONObject object;
        for (int i = 0; i < jArray.length(); i++) {
            object = jArray.getJSONObject(i);
            results.add(object.getString(field));
        }
        return results;
    }
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:25,代码来源:JSONUtils.java


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