org.json.JSONException.getLocalizedMessage()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.json.JSONException.getLocalizedMessage()方法的一些代码示例,展示了JSONException.getLocalizedMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONException.getLocalizedMessage()方法的具体详情如下:
包路径:org.json.JSONException
类名称:JSONException
方法名:getLocalizedMessage

JSONException.getLocalizedMessage介绍

暂无

代码示例

代码示例来源:origin: facebook/facebook-android-sdk

stagedObject.put("user_generated", photo.getUserGenerated());
} catch (final JSONException ex) {
  String message = ex.getLocalizedMessage();
  if (message == null) {
    message = "Error staging photo.";

代码示例来源:origin: ukanth/afwall

Log.e(TAG, e.getLocalizedMessage());
} catch (JSONException e) {
  Log.e(TAG, e.getLocalizedMessage());
} finally {
  if (br != null) {

代码示例来源:origin: ukanth/afwall

public static boolean exportRules(Context ctx, final String fileName) {
  boolean res = false;
  File sdCard = Environment.getExternalStorageDirectory();
  if (isExternalStorageWritable()) {
    File dir = new File(sdCard.getAbsolutePath() + "/afwall/");
    dir.mkdirs();
    File file = new File(dir, fileName);
    try {
      FileOutputStream fOut = new FileOutputStream(file);
      OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
      //default Profile - current one
      JSONObject obj = new JSONObject(getCurrentRulesAsMap(ctx));
      JSONArray jArray = new JSONArray("[" + obj.toString() + "]");
      myOutWriter.append(jArray.toString());
      res = true;
      myOutWriter.close();
      fOut.close();
    } catch (FileNotFoundException e) {
      Log.e(TAG, e.getLocalizedMessage());
    } catch (JSONException e) {
      Log.e(TAG, e.getLocalizedMessage());
    } catch (IOException e) {
      Log.e(TAG, e.getLocalizedMessage());
    }
  }
  return res;
}

代码示例来源:origin: ukanth/afwall

private static Map<String, JSONObject> getCurrentRulesAsMap(Context ctx) {
  List<PackageInfoData> apps = getApps(ctx, null);
  // Builds a pipe-separated list of names
  Map<String, JSONObject> exportMap = new HashMap<>();
  try {
    for (int i = 0; i < apps.size(); i++) {
      if (apps.get(i).selected_wifi) {
        updateExportPackage(exportMap, apps.get(i).pkgName, WIFI_EXPORT);
      }
      if (apps.get(i).selected_3g) {
        updateExportPackage(exportMap, apps.get(i).pkgName, DATA_EXPORT);
      }
      if (apps.get(i).selected_roam) {
        updateExportPackage(exportMap, apps.get(i).pkgName, ROAM_EXPORT);
      }
      if (apps.get(i).selected_vpn) {
        updateExportPackage(exportMap, apps.get(i).pkgName, VPN_EXPORT);
      }
      if (apps.get(i).selected_lan) {
        updateExportPackage(exportMap, apps.get(i).pkgName, LAN_EXPORT);
      }
      if (apps.get(i).selected_tor) {
        updateExportPackage(exportMap, apps.get(i).pkgName, TOR_EXPORT);
      }
    }
  } catch (JSONException e) {
    Log.e(TAG, e.getLocalizedMessage());
  }
  return exportMap;
}

代码示例来源:origin: ukanth/afwall

Log.e(TAG, e.getLocalizedMessage());
} catch (JSONException e) {
  Log.e(TAG, e.getLocalizedMessage());
} finally {
  if (br != null) {

代码示例来源:origin: ukanth/afwall

Log.d(TAG, e.getLocalizedMessage());
} catch (JSONException e) {
  Log.d(TAG, e.getLocalizedMessage());
} catch (Exception e) {
  Log.d(TAG, e.getLocalizedMessage());

代码示例来源:origin: dongjunkun/GanK

callBack.onFailure(e.getLocalizedMessage());

代码示例来源:origin: tomahawk-player/tomahawk-android

public static void putFloatArray(SharedPreferences.Editor editor, String key, float[] array) {
  try {
    JSONArray json = new JSONArray();
    for (float f : array) {
      json.put(f);
    }
    editor.putString(key, json.toString());
  } catch (JSONException e) {
    Log.e(TAG, "putFloatArray: " + e.getClass() + ": " + e.getLocalizedMessage());
  }
}

代码示例来源:origin: org.restlet.jse/org.restlet.ext.json

@Override
  public void write(Writer writer) throws IOException {
    try {
      writer.write(getJsonText());
    } catch (JSONException e) {
      IOException ioe = new IOException(e.getLocalizedMessage());
      ioe.initCause(e.getCause());
      throw ioe;
    }
  }
}

代码示例来源:origin: dividiti/crowdsource-video-experiments-on-android

public static void saveScenariosJSONObjectToFile(JSONObject scenariousJSON) {
  try {
    openme.openme_store_json_file(scenariousJSON, cachedScenariosFilePath);
  } catch (JSONException e) {
    AppLogger.logMessage("ERROR could save scenarios to file " + cachedScenariosFilePath + " because of the error " + e.getLocalizedMessage());
    return;
  }
}

代码示例来源:origin: stripe/stripe-android

@Test(expected = AssertionError.class)
public void assertJsonEquals_forSimpleUnequalObjects_fails() {
  String simpleJson = "{\"key\": \"value\"}";
  String differentJson = "{\"key2\": \"value2\"}";
  try {
    JSONObject first = new JSONObject(simpleJson);
    JSONObject second = new JSONObject(differentJson);
    JsonTestUtils.assertJsonEquals(first, second);
  } catch (JSONException dataException) {
    fail("Test data failure: " + dataException.getLocalizedMessage());
  }
}

代码示例来源:origin: stripe/stripe-android

@Test(expected = AssertionError.class)
public void assertJsonEquals_forSimpleUnequalObjectsWithSameKey_fails() {
  String simpleJson = "{\"key\": \"value\"}";
  String differentJson = "{\"key\": \"value2\"}";
  try {
    JSONObject first = new JSONObject(simpleJson);
    JSONObject second = new JSONObject(differentJson);
    JsonTestUtils.assertJsonEquals(first, second);
  } catch (JSONException dataException) {
    fail("Test data failure: " + dataException.getLocalizedMessage());
  }
}

代码示例来源:origin: stripe/stripe-android

@Test
public void putAdditionalFieldsIntoJsonObject_whenNoFieldsArePassed_doesNothing() {
  JSONObject jsonObject = new JSONObject();
  try {
    jsonObject.put("a", "a_value");
  } catch (JSONException unexpected) {
    fail("Unexpected error: " + unexpected.getLocalizedMessage());
  }
  Map<String, Object> emptyMap = new HashMap<>();
  putAdditionalFieldsIntoJsonObject(jsonObject, emptyMap);
  assertEquals(1, jsonObject.length());
}

代码示例来源:origin: stripe/stripe-android

@Test
public void assertJsonEquals_forSimpleObjectsWithNumbers_passes() {
  String simpleJson = "{\"key\": \"value\", \"key2\": 100}";
  try {
    JSONObject first = new JSONObject(simpleJson);
    JSONObject second = new JSONObject(simpleJson);
    JsonTestUtils.assertJsonEquals(first, second);
  } catch (JSONException dataException) {
    fail("Test data failure: " + dataException.getLocalizedMessage());
  }
}

代码示例来源:origin: stripe/stripe-android

@Test(expected = AssertionError.class)
public void assertJsonEquals_forSimpleObjectsOfDifferentSize_fails() {
  String simpleJson = "{\"key\": \"value\"}";
  String differentJson = "{\"key\": \"value\", \"key2\": \"value2\"}";
  try {
    JSONObject first = new JSONObject(simpleJson);
    JSONObject second = new JSONObject(differentJson);
    JsonTestUtils.assertJsonEquals(first, second);
  } catch (JSONException dataException) {
    fail("Test data failure: " + dataException.getLocalizedMessage());
  }
}

代码示例来源:origin: stripe/stripe-android

@Test
public void fromJsonString_backToJson_createsIdenticalElement() {
  try {
    JSONObject rawConversion = new JSONObject(EXAMPLE_JSON_ADDRESS);
    assertJsonEquals(rawConversion, mAddress.toJson());
  } catch (JSONException jsonException) {
    fail("Test Data failure: " + jsonException.getLocalizedMessage());
  }
}

代码示例来源:origin: stripe/stripe-android

@Test
public void fromJsonString_backToJson_createsIdenticalElement() {
  try {
    JSONObject rawConversion = new JSONObject(EXAMPLE_JSON_REDIRECT);
    assertJsonEquals(rawConversion, mSourceRedirect.toJson());
  } catch (JSONException jsonException) {
    fail("Test Data failure: " + jsonException.getLocalizedMessage());
  }
}

代码示例来源:origin: stripe/stripe-android

@Test
public void fromJsonStringWithoutNulls_backToJson_createsIdenticalElement() {
  try {
    JSONObject rawConversion = new JSONObject(EXAMPLE_JSON_OWNER_WITHOUT_NULLS);
    assertJsonEquals(rawConversion, mSourceOwner.toJson());
  } catch (JSONException jsonException) {
    fail("Test Data failure: " + jsonException.getLocalizedMessage());
  }
}

代码示例来源:origin: stripe/stripe-android

@Test
public void fromJsonString_backToJson_createsIdenticalElement() {
  try {
    JSONObject rawConversion = new JSONObject(EXAMPLE_PAYMENT_INTENT_SOURCE);
    JSONObject actualObject = mPaymentIntent.toJson();
    assertJsonEqualsExcludingNulls(rawConversion, actualObject);
  } catch (JSONException jsonException) {
    fail("Test Data failure: " + jsonException.getLocalizedMessage());
  }
}

代码示例来源:origin: stripe/stripe-android

@Test
public void fromJsonString_backToJson_createsIdenticalElement() {
  try {
    JSONObject rawConversion = new JSONObject(EXAMPLE_JSON_RECEIVER);
    assertJsonEquals(rawConversion, mSourceReceiver.toJson());
  } catch (JSONException jsonException) {
    fail("Test Data failure: " + jsonException.getLocalizedMessage());
  }
}

相关文章