List of usage examples for org.json JSONObject get
public Object get(String key) throws JSONException
From source file:test.Testing.java
public static void main(String[] args) throws Exception { //////////////////////////////////////////////////////////////////////////////////////////// // Setup/*from ww w.java2 s . co m*/ //////////////////////////////////////////////////////////////////////////////////////////// String key = "CHANGEME: YOUR_API_KEY"; String secret = "CHANGEME: YOUR_API_SECRET"; String version = "preview1"; String practiceid = "000000"; APIConnection api = new APIConnection(version, key, secret, practiceid); api.authenticate(); // If you want to set the practice ID after construction, this is how. // api.setPracticeID("000000"); //////////////////////////////////////////////////////////////////////////////////////////// // GET without parameters //////////////////////////////////////////////////////////////////////////////////////////// JSONArray customfields = (JSONArray) api.GET("/customfields"); System.out.println("Custom fields:"); for (int i = 0; i < customfields.length(); i++) { System.out.println("\t" + customfields.getJSONObject(i).get("name")); } //////////////////////////////////////////////////////////////////////////////////////////// // GET with parameters //////////////////////////////////////////////////////////////////////////////////////////// SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); Calendar today = Calendar.getInstance(); Calendar nextyear = Calendar.getInstance(); nextyear.roll(Calendar.YEAR, 1); Map<String, String> search = new HashMap<String, String>(); search.put("departmentid", "82"); search.put("startdate", format.format(today.getTime())); search.put("enddate", format.format(nextyear.getTime())); search.put("appointmenttypeid", "2"); search.put("limit", "1"); JSONObject open_appts = (JSONObject) api.GET("/appointments/open", search); System.out.println(open_appts.toString()); JSONObject appt = open_appts.getJSONArray("appointments").getJSONObject(0); System.out.println("Open appointment:"); System.out.println(appt.toString()); // add keys to make appt usable for scheduling appt.put("appointmenttime", appt.get("starttime")); appt.put("appointmentdate", appt.get("date")); //////////////////////////////////////////////////////////////////////////////////////////// // POST with parameters //////////////////////////////////////////////////////////////////////////////////////////// Map<String, String> patient_info = new HashMap<String, String>(); patient_info.put("lastname", "Foo"); patient_info.put("firstname", "Jason"); patient_info.put("address1", "123 Any Street"); patient_info.put("city", "Cambridge"); patient_info.put("countrycode3166", "US"); patient_info.put("departmentid", "1"); patient_info.put("dob", "6/18/1987"); patient_info.put("language6392code", "declined"); patient_info.put("maritalstatus", "S"); patient_info.put("race", "declined"); patient_info.put("sex", "M"); patient_info.put("ssn", "*****1234"); patient_info.put("zip", "02139"); JSONArray new_patient = (JSONArray) api.POST("/patients", patient_info); String new_patient_id = new_patient.getJSONObject(0).getString("patientid"); System.out.println("New patient id:"); System.out.println(new_patient_id); //////////////////////////////////////////////////////////////////////////////////////////// // PUT with parameters //////////////////////////////////////////////////////////////////////////////////////////// Map<String, String> appointment_info = new HashMap<String, String>(); appointment_info.put("appointmenttypeid", "82"); appointment_info.put("departmentid", "1"); appointment_info.put("patientid", new_patient_id); JSONArray booked = (JSONArray) api.PUT("/appointments/" + appt.getString("appointmentid"), appointment_info); System.out.println("Booked:"); System.out.println(booked.toString()); //////////////////////////////////////////////////////////////////////////////////////////// // POST without parameters //////////////////////////////////////////////////////////////////////////////////////////// JSONObject checked_in = (JSONObject) api .POST("/appointments/" + appt.getString("appointmentid") + "/checkin"); System.out.println("Check-in:"); System.out.println(checked_in.toString()); //////////////////////////////////////////////////////////////////////////////////////////// // DELETE with parameters //////////////////////////////////////////////////////////////////////////////////////////// Map<String, String> delete_params = new HashMap<String, String>(); delete_params.put("departmentid", "1"); JSONObject chart_alert = (JSONObject) api.DELETE("/patients/" + new_patient_id + "/chartalert", delete_params); System.out.println("Removed chart alert:"); System.out.println(chart_alert.toString()); //////////////////////////////////////////////////////////////////////////////////////////// // DELETE without parameters //////////////////////////////////////////////////////////////////////////////////////////// JSONObject photo = (JSONObject) api.DELETE("/patients/" + new_patient_id + "/photo"); System.out.println("Removed photo:"); System.out.println(photo.toString()); //////////////////////////////////////////////////////////////////////////////////////////// // There are no PUTs without parameters //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// // Error conditions //////////////////////////////////////////////////////////////////////////////////////////// JSONObject bad_path = (JSONObject) api.GET("/nothing/at/this/path"); System.out.println("GET /nothing/at/this/path:"); System.out.println(bad_path.toString()); JSONObject missing_parameters = (JSONObject) api.GET("/appointments/open"); System.out.println("Missing parameters:"); System.out.println(missing_parameters.toString()); //////////////////////////////////////////////////////////////////////////////////////////// // Testing token refresh // // NOTE: this test takes an hour, so it's disabled by default. Change false to true to run. //////////////////////////////////////////////////////////////////////////////////////////// if (false) { String old_token = api.getToken(); System.out.println("Old token: " + old_token); JSONObject before_refresh = (JSONObject) api.GET("/departments"); // Wait 3600 seconds = 1 hour for token to expire. try { Thread.sleep(3600 * 1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } JSONObject after_refresh = (JSONObject) api.GET("/departments"); System.out.println("New token: " + api.getToken()); } }
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Open the notification in NotificationActivity * @param args/* w ww . j a va 2 s . c om*/ * @param callbackContext */ protected void openNotification(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "OPENNOTIFICATION"); try { JSONObject notificationJSON = args.getJSONObject(0); // Workaround for pre-1.1.1 SDK notificationJSON.put("_id", notificationJSON.get("notificationId")); NotificareNotification notification = new NotificareNotification(notificationJSON); Intent notificationIntent = new Intent() .setClass(Notificare.shared().getApplicationContext(), NotificationActivity.class) .setAction(Notificare.INTENT_ACTION_NOTIFICATION_OPENED) .putExtra(Notificare.INTENT_EXTRA_NOTIFICATION, notification) .putExtra(Notificare.INTENT_EXTRA_DISPLAY_MESSAGE, Notificare.shared().getDisplayMessage()) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); if (notificationJSON.optString("itemId", null) != null) { notificationIntent.putExtra(Notificare.INTENT_EXTRA_INBOX_ITEM_ID, notificationJSON.getString("itemId")); } cordova.getActivity().startActivity(notificationIntent); if (callbackContext == null) { return; } callbackContext.success(); } catch (JSONException e) { if (callbackContext == null) { return; } callbackContext.error("JSON parse error"); } }
From source file:it.moondroid.chatbot.alice.Sraix.java
public static String sraixPannous(String input, String hint, Chat chatSession) { try {//www. j av a2 s .c o m String rawInput = input; if (hint == null) hint = MagicStrings.sraix_no_hint; input = " " + input + " "; input = input.replace(" point ", "."); input = input.replace(" rparen ", ")"); input = input.replace(" lparen ", "("); input = input.replace(" slash ", "/"); input = input.replace(" star ", "*"); input = input.replace(" dash ", "-"); // input = chatSession.bot.preProcessor.denormalize(input); input = input.trim(); input = input.replace(" ", "+"); int offset = CalendarUtils.timeZoneOffset(); //System.out.println("OFFSET = "+offset); String locationString = ""; if (chatSession.locationKnown) { locationString = "&location=" + chatSession.latitude + "," + chatSession.longitude; } // https://weannie.pannous.com/api?input=when+is+daylight+savings+time+in+the+us&locale=en_US&login=pandorabots&ip=169.254.178.212&botid=0&key=CKNgaaVLvNcLhDupiJ1R8vtPzHzWc8mhIQDFSYWj&exclude=Dialogues,ChatBot&out=json // exclude=Dialogues,ChatBot&out=json&clientFeatures=show-images,reminder,say&debug=true String url = "https://ask.pannous.com/api?input=" + input + "&locale=en_US&timeZone=" + offset + locationString + "&login=" + MagicStrings.pannous_login + "&ip=" + NetworkUtils.localIPAddress() + "&botid=0&key=" + MagicStrings.pannous_api_key + "&exclude=Dialogues,ChatBot&out=json&clientFeatures=show-images,reminder,say&debug=true"; MagicBooleans.trace("in Sraix.sraixPannous, url: '" + url + "'"); String page = NetworkUtils.responseContent(url); //MagicBooleans.trace("in Sraix.sraixPannous, page: " + page); String text = ""; String imgRef = ""; String urlRef = ""; if (page == null || page.length() == 0) { text = MagicStrings.sraix_failed; } else { JSONArray outputJson = new JSONObject(page).getJSONArray("output"); //MagicBooleans.trace("in Sraix.sraixPannous, outputJson class: " + outputJson.getClass() + ", outputJson: " + outputJson); if (outputJson.length() == 0) { text = MagicStrings.sraix_failed; } else { JSONObject firstHandler = outputJson.getJSONObject(0); //MagicBooleans.trace("in Sraix.sraixPannous, firstHandler class: " + firstHandler.getClass() + ", firstHandler: " + firstHandler); JSONObject actions = firstHandler.getJSONObject("actions"); //MagicBooleans.trace("in Sraix.sraixPannous, actions class: " + actions.getClass() + ", actions: " + actions); if (actions.has("reminder")) { //MagicBooleans.trace("in Sraix.sraixPannous, found reminder action"); Object obj = actions.get("reminder"); if (obj instanceof JSONObject) { if (MagicBooleans.trace_mode) System.out.println("Found JSON Object"); JSONObject sObj = (JSONObject) obj; String date = sObj.getString("date"); date = date.substring(0, "2012-10-24T14:32".length()); if (MagicBooleans.trace_mode) System.out.println("date=" + date); String duration = sObj.getString("duration"); if (MagicBooleans.trace_mode) System.out.println("duration=" + duration); Pattern datePattern = Pattern.compile("(.*)-(.*)-(.*)T(.*):(.*)"); Matcher m = datePattern.matcher(date); String year = "", month = "", day = "", hour = "", minute = ""; if (m.matches()) { year = m.group(1); month = String.valueOf(Integer.parseInt(m.group(2)) - 1); day = m.group(3); hour = m.group(4); minute = m.group(5); text = "<year>" + year + "</year>" + "<month>" + month + "</month>" + "<day>" + day + "</day>" + "<hour>" + hour + "</hour>" + "<minute>" + minute + "</minute>" + "<duration>" + duration + "</duration>"; } else text = MagicStrings.schedule_error; } } else if (actions.has("say") && !hint.equals(MagicStrings.sraix_pic_hint) && !hint.equals(MagicStrings.sraix_shopping_hint)) { MagicBooleans.trace("in Sraix.sraixPannous, found say action"); Object obj = actions.get("say"); //MagicBooleans.trace("in Sraix.sraixPannous, obj class: " + obj.getClass()); //MagicBooleans.trace("in Sraix.sraixPannous, obj instanceof JSONObject: " + (obj instanceof JSONObject)); if (obj instanceof JSONObject) { JSONObject sObj = (JSONObject) obj; text = sObj.getString("text"); if (sObj.has("moreText")) { JSONArray arr = sObj.getJSONArray("moreText"); for (int i = 0; i < arr.length(); i++) { text += " " + arr.getString(i); } } } else { text = obj.toString(); } } if (actions.has("show") && !text.contains("Wolfram") && actions.getJSONObject("show").has("images")) { MagicBooleans.trace("in Sraix.sraixPannous, found show action"); JSONArray arr = actions.getJSONObject("show").getJSONArray("images"); int i = (int) (arr.length() * Math.random()); //for (int j = 0; j < arr.length(); j++) System.out.println(arr.getString(j)); imgRef = arr.getString(i); if (imgRef.startsWith("//")) imgRef = "http:" + imgRef; imgRef = "<a href=\"" + imgRef + "\"><img src=\"" + imgRef + "\"/></a>"; //System.out.println("IMAGE REF="+imgRef); } if (hint.equals(MagicStrings.sraix_shopping_hint) && actions.has("open") && actions.getJSONObject("open").has("url")) { urlRef = "<oob><url>" + actions.getJSONObject("open").getString("url") + "</oob></url>"; } } if (hint.equals(MagicStrings.sraix_event_hint) && !text.startsWith("<year>")) return MagicStrings.sraix_failed; else if (text.equals(MagicStrings.sraix_failed)) return AIMLProcessor.respond(MagicStrings.sraix_failed, "nothing", "nothing", chatSession); else { text = text.replace("'", "'"); text = text.replace("'", "'"); text = text.replaceAll("\\[(.*)\\]", ""); String[] sentences; sentences = text.split("\\. "); //System.out.println("Sraix: text has "+sentences.length+" sentences:"); String clippedPage = sentences[0]; for (int i = 1; i < sentences.length; i++) { if (clippedPage.length() < 500) clippedPage = clippedPage + ". " + sentences[i]; //System.out.println(i+". "+sentences[i]); } clippedPage = clippedPage + " " + imgRef + " " + urlRef; clippedPage = clippedPage.trim(); log(rawInput, clippedPage); return clippedPage; } } } catch (Exception ex) { ex.printStackTrace(); System.out.println("Sraix '" + input + "' failed"); } return MagicStrings.sraix_failed; }
From source file:org.eclipse.flux.client.SingleResponseHandler.java
/** * Should inspect the message to determine if it is an 'error' * response and throw an exception in that case. Do nothing otherwise. */// ww w . j a v a 2 s. co m protected void errorParse(String messageType, JSONObject message) throws Exception { if (message.has(ERROR)) { if (message.has("errorDetails")) { System.err.println(message.get("errorDetails")); } throw new Exception(message.getString(ERROR)); } }
From source file:org.nuclearbunny.icybee.net.impl.BitlyImpl.java
public String shrinkURL(String url) throws IOException { /**//from w w w.j av a 2 s.c o m * bit.ly provides an elegant REST API that returns results in either JSON * or XML format. See http://bitly.com/app/developers for more information. */ StringBuilder buffer = new StringBuilder(BITLY_URL); buffer.append("?version=2.0.1").append("&format=json").append("&login=").append(BITLY_API_LOGIN) .append("&apiKey=").append(BITLY_API_KEY).append("&longUrl=") .append(URLEncoder.encode(url, "UTF-8")); URL bitlyURL = new URL(buffer.toString()); URLConnection connection = bitlyURL.openConnection(); String newURL = url; try { BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); JSONObject jsonObject = new JSONObject(new JSONTokener(in)); if ("OK".equals(jsonObject.opt("statusCode"))) { JSONObject results = (JSONObject) jsonObject.get("results"); results = (JSONObject) results.get(url); newURL = results.get("shortUrl").toString(); } } catch (JSONException e) { e.printStackTrace(System.err); throw new IOException(e.getMessage()); } return newURL; }
From source file:ch.icclab.cyclops.resource.impl.ExternalAppResource.java
/** * Receives the JSON array, transforms it and send it to the db resource to persist it into InfluxDB * * Pseudo Code/*from ww w . j av a 2 s. c o m*/ * 1. Iterate through the JSONArray to get the JSON obj * 2. Iterate through the JSON Obj to get the usage details * 3. Build the TSDB POJO * 4. Pass this POJO obj to the TSDB resource for persisting it into the DB * * @param jsonArr An array containing the usage data as part of JSON Objects * @return String */ public boolean saveData(JSONArray jsonArr) { JSONObject jsonObj, metadata, usageData; String metername = null; String source; TSDBResource dbResource = new TSDBResource(); JSONArray dataArr; ArrayList<Object> objArrNode; ArrayList<ArrayList<Object>> objArr = new ArrayList<ArrayList<Object>>(); TSDBData dbData = new TSDBData(); ArrayList<String> columnNameArr = new ArrayList<String>(); columnNameArr.add("timestamp"); columnNameArr.add("userid"); columnNameArr.add("source"); columnNameArr.add("usage"); try { for (int i = 0; i < jsonArr.length(); i++) { jsonObj = (JSONObject) jsonArr.get(i); metadata = (JSONObject) jsonObj.get("metadata"); source = (String) metadata.get("source"); dataArr = (JSONArray) jsonObj.get("usage"); for (int j = 0; j < dataArr.length(); j++) { objArrNode = new ArrayList<Object>(); usageData = (JSONObject) dataArr.get(j); metername = (String) usageData.get("metername"); objArrNode.add(usageData.get("timestamp")); objArrNode.add(usageData.get("userid")); objArrNode.add(source); objArrNode.add(usageData.get("usage")); objArr.add(objArrNode); } dbData.setName(metername); dbData.setColumns(columnNameArr); dbData.setPoints(objArr); dbResource.saveExtData(dbData); } } catch (JSONException e) { e.printStackTrace(); return false; } return true; }
From source file:org.eclipse.orion.server.tests.servlets.git.GitCherryPickTest.java
@Test public void testCherryPick() throws Exception { URI workspaceLocation = createWorkspace(getMethodName()); IPath[] clonePaths = createTestProjects(workspaceLocation); for (IPath clonePath : clonePaths) { // clone a repo JSONObject clone = clone(clonePath); String cloneLocation = clone.getString(ProtocolConstants.KEY_LOCATION); String cloneContentLocation = clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION); String branchesLocation = clone.getString(GitConstants.KEY_BRANCH); // get project/folder metadata WebRequest request = getGetRequest(cloneContentLocation); WebResponse response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); JSONObject folder = new JSONObject(response.getText()); String folderLocation = folder.getString(ProtocolConstants.KEY_LOCATION); JSONObject gitSection = folder.getJSONObject(GitConstants.KEY_GIT); String gitIndexUri = gitSection.getString(GitConstants.KEY_INDEX); String gitHeadUri = gitSection.getString(GitConstants.KEY_HEAD); JSONObject testTxt = getChild(folder, "test.txt"); modifyFile(testTxt, "first line\nsec. line\nthird line\n"); addFile(testTxt);/*from ww w . j ava 2s. co m*/ commitFile(testTxt, "lines in test.txt", false); // create new file String fileName = "new.txt"; request = getPostFilesRequest(folderLocation + "/", getNewFileJSON(fileName).toString(), fileName); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode()); // add all request = GitAddTest.getPutGitIndexRequest(gitIndexUri); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); // commit request = GitCommitTest.getPostGitCommitRequest(gitHeadUri, "added new.txt", false); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); // modify modifyFile(testTxt, "first line\nsec. line\nthird line\nfourth line\n"); // add addFile(testTxt); // commit request = GitCommitTest.getPostGitCommitRequest(gitHeadUri, "enlarged test.txt", false); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); // modify modifyFile(testTxt, "first line\nsecond line\nthird line\nfourth line\n"); // add addFile(testTxt); // commit request = GitCommitTest.getPostGitCommitRequest(gitHeadUri, "fixed test.txt", false); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); // remember starting point and commit to cherry-pick JSONArray commitsArray = log(gitHeadUri); assertEquals(5, commitsArray.length()); JSONObject commit = commitsArray.getJSONObject(0); assertEquals("fixed test.txt", commit.get(GitConstants.KEY_COMMIT_MESSAGE)); String toCherryPick = commit.getString(ProtocolConstants.KEY_NAME); commit = commitsArray.getJSONObject(3); assertEquals("lines in test.txt", commit.get(GitConstants.KEY_COMMIT_MESSAGE)); String startingPoint = commit.getString(ProtocolConstants.KEY_NAME); // branch response = branch(branchesLocation, "side", startingPoint); assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode()); response = checkoutBranch(cloneLocation, "side"); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); // modify modifyFile(testTxt, "first line\nsec. line\nthird line\nfeature++\n"); // add addFile(testTxt); // commit request = GitCommitTest.getPostGitCommitRequest(gitHeadUri, "enhanced test.txt", false); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); // CHERRY-PICK JSONObject cherryPick = cherryPick(gitHeadUri, toCherryPick); CherryPickStatus mergeResult = CherryPickStatus.valueOf(cherryPick.getString(GitConstants.KEY_RESULT)); assertEquals(CherryPickStatus.OK, mergeResult); assertTrue(cherryPick.getBoolean(GitConstants.KEY_HEAD_UPDATED)); // try again, should be OK, but nothing changed cherryPick = cherryPick(gitHeadUri, toCherryPick); mergeResult = CherryPickStatus.valueOf(cherryPick.getString(GitConstants.KEY_RESULT)); assertEquals(CherryPickStatus.OK, mergeResult); assertFalse(cherryPick.getBoolean(GitConstants.KEY_HEAD_UPDATED)); // 'new.txt' should be not there JSONObject newTxt = getChild(folder, "new.txt"); assertNull(newTxt); // check cherry-pick result in the file request = getGetRequest(testTxt.getString(ProtocolConstants.KEY_LOCATION)); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); assertEquals("first line\nsecond line\nthird line\nfeature++\n", response.getText()); // check log commitsArray = log(gitHeadUri); assertEquals(4, commitsArray.length()); commit = commitsArray.getJSONObject(0); assertEquals("fixed test.txt", commit.get(GitConstants.KEY_COMMIT_MESSAGE)); commit = commitsArray.getJSONObject(1); assertEquals("enhanced test.txt", commit.get(GitConstants.KEY_COMMIT_MESSAGE)); commit = commitsArray.getJSONObject(2); assertEquals("lines in test.txt", commit.get(GitConstants.KEY_COMMIT_MESSAGE)); commit = commitsArray.getJSONObject(3); assertEquals("Initial commit", commit.get(GitConstants.KEY_COMMIT_MESSAGE)); } }
From source file:blink.Message.java
/** * a Message object that represents a received message that will be processed from JSON * @param jsonReceived given JSON content of the message * @throws JSONException //from w ww . j a v a2s . c om */ public Message(String jsonReceived) { JSONObject json; try { json = new JSONObject(jsonReceived); if (json.has("timestamp")) { timestamp = Long.parseLong((String) json.get("timestamp")); } if (json.has("content")) { text = (String) json.get("content"); } userId = i++; try { type = (String) json.get("type"); } catch (Exception e) { System.err.println("Error receiving message. No type in JSON received."); System.exit(-1); } } catch (JSONException ex) { Logger.getLogger(Message.class.getName()).log(Level.SEVERE, null, ex); } this.json = jsonReceived; }
From source file:org.rapidandroid.activity.FormCreator.java
@Override protected synchronized void onResume() { super.onResume(); Intent intent = getIntent();/*from w w w .j a v a2s. c o m*/ String currentForm = intent.getStringExtra("current_form"); if (currentForm != null) { try { String contents = new String(currentForm); JSONObject readobject = new JSONObject(contents); EditText etxFormName = (EditText) findViewById(R.id.etx_formname); EditText etxFormPrefix = (EditText) findViewById(R.id.etx_formprefix); EditText etxDescription = (EditText) findViewById(R.id.etx_description); etxFormName.setText(readobject.getString(STATE_FORMNAME)); etxFormPrefix.setText(readobject.getString(STATE_PREFIX)); etxDescription.setText(readobject.getString(STATE_DESC)); boolean checkForFields = true; int i = 0; do { checkForFields = readobject.has("Field" + i); if (checkForFields) { JSONObject fieldBundle = (JSONObject) readobject.get("Field" + i); restoreFieldFromState(fieldBundle); i++; } } while (checkForFields); } catch (Exception e) { Log.e("FOOBAR", e.getMessage(), e); } } }
From source file:tools.xor.MutableJsonProperty.java
private Object toDomain(JSONObject jsonObject, String key) throws JSONException { if (getConverter() != null) { return getConverter().toDomain(jsonObject, key); } else {/*from w w w . j a v a2 s . c om*/ if (logger.isDebugEnabled()) { logger.debug("DynamicProperty#toDomain: Unknown converter for " + getType().getInstanceClass() + ", jsonValue: " + jsonObject.get(key) + ", type name: " + getType().getName() + ", domain type: " + getDomainProperty().getType().getInstanceClass().getName()); } return jsonObject.get(key); } }