本文整理了Java中org.json.JSONException.<init>()
方法的一些代码示例,展示了JSONException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONException.<init>()
方法的具体详情如下:
包路径:org.json.JSONException
类名称:JSONException
方法名:<init>
[英]Constructs a JSONException with an explanatory message.
[中]构造带有解释性消息的JSONException。
代码示例来源:origin: zzz40500/GsonFormat
/**
* Back up one character. This provides a sort of lookahead capability,
* so that you can test for a digit or letter before attempting to parse
* the next number or identifier.
*/
public void back() throws JSONException {
if (this.usePrevious || this.index <= 0) {
throw new JSONException("Stepping back two steps is not supported");
}
this.index -= 1;
this.character -= 1;
this.usePrevious = true;
this.eof = false;
}
代码示例来源:origin: robovm/robovm
/**
* Returns an exception containing the given message plus the current
* position and the entire input string.
*/
public JSONException syntaxError(String message) {
return new JSONException(message + this);
}
代码示例来源:origin: robovm/robovm
String checkName(String name) throws JSONException {
if (name == null) {
throw new JSONException("Names must be non-null");
}
return name;
}
代码示例来源:origin: apache/geode
String checkName(String name) throws JSONException {
if (name == null) {
throw new JSONException("Names must be non-null");
}
return name;
}
代码示例来源:origin: apache/geode
/**
* Returns an exception containing the given message plus the current position and the entire
* input string.
*
* @param message The message we want to include.
* @return An exception that we can throw.
*/
public JSONException syntaxError(String message) {
return new JSONException(message + this);
}
代码示例来源:origin: robovm/robovm
/**
* Returns the value mapped by {@code name}.
*
* @throws JSONException if no such mapping exists.
*/
public Object get(String name) throws JSONException {
Object result = nameValuePairs.get(name);
if (result == null) {
throw new JSONException("No value for " + name);
}
return result;
}
代码示例来源:origin: robovm/robovm
public static JSONException typeMismatch(Object indexOrName, Object actual,
String requiredType) throws JSONException {
if (actual == null) {
throw new JSONException("Value at " + indexOrName + " is null.");
} else {
throw new JSONException("Value " + actual + " at " + indexOrName
+ " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
}
}
代码示例来源:origin: robovm/robovm
public static JSONException typeMismatch(Object actual, String requiredType)
throws JSONException {
if (actual == null) {
throw new JSONException("Value is null.");
} else {
throw new JSONException("Value " + actual
+ " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
}
}
}
代码示例来源:origin: apache/geode
public static JSONException typeMismatch(Object actual, String requiredType)
throws JSONException {
if (actual == null) {
throw new JSONException("Value is null.");
} else {
throw new JSONException("Value " + actual + " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
}
}
}
代码示例来源:origin: apache/geode
public static JSONException typeMismatch(Object indexOrName, Object actual, String requiredType)
throws JSONException {
if (actual == null) {
throw new JSONException("Value at " + indexOrName + " is null.");
} else {
throw new JSONException("Value " + actual + " at " + indexOrName + " of type "
+ actual.getClass().getName() + " cannot be converted to " + requiredType);
}
}
代码示例来源:origin: robovm/robovm
/**
* Returns the input if it is a JSON-permissible value; throws otherwise.
*/
static double checkDouble(double d) throws JSONException {
if (Double.isInfinite(d) || Double.isNaN(d)) {
throw new JSONException("Forbidden numeric value: " + d);
}
return d;
}
代码示例来源:origin: apache/geode
/**
* Returns the input if it is a JSON-permissible value; throws otherwise.
*/
static double checkDouble(double d) throws JSONException {
if (Double.isInfinite(d) || Double.isNaN(d)) {
throw new JSONException("Forbidden numeric value: " + d);
}
return d;
}
代码示例来源:origin: robovm/robovm
/**
* Returns the value on the top of the stack.
*/
private Scope peek() throws JSONException {
if (stack.isEmpty()) {
throw new JSONException("Nesting problem");
}
return stack.get(stack.size() - 1);
}
代码示例来源:origin: apache/geode
/**
* Returns the value on the top of the stack.
*/
private Scope peek() throws JSONException {
if (stack.isEmpty()) {
throw new JSONException("Nesting problem");
}
return stack.get(stack.size() - 1);
}
代码示例来源:origin: zzz40500/GsonFormat
/**
* Make a JSONException to signal a syntax error.
*
* @param message The error message.
* @return A JSONException object, suitable for throwing
*/
public JSONException syntaxError(String message) {
return new JSONException(message + this.toString());
}
代码示例来源:origin: apache/geode
/**
* Enters a new scope by appending any necessary whitespace and the given bracket.
*/
JSONStringer open(Scope empty, String openBracket) throws JSONException {
if (stack.isEmpty() && out.length() > 0) {
throw new JSONException("Nesting problem: multiple top-level roots");
}
beforeValue();
stack.add(empty);
out.append(openBracket);
return this;
}
代码示例来源:origin: robovm/robovm
/**
* Encodes {@code value} to this stringer.
*
* @return this stringer.
*/
public JSONStringer value(boolean value) throws JSONException {
if (stack.isEmpty()) {
throw new JSONException("Nesting problem");
}
beforeValue();
out.append(value);
return this;
}
代码示例来源:origin: robovm/robovm
/**
* Encodes {@code value} to this stringer.
*
* @return this stringer.
*/
public JSONStringer value(long value) throws JSONException {
if (stack.isEmpty()) {
throw new JSONException("Nesting problem");
}
beforeValue();
out.append(value);
return this;
}
代码示例来源:origin: robovm/robovm
/**
* Enters a new scope by appending any necessary whitespace and the given
* bracket.
*/
JSONStringer open(Scope empty, String openBracket) throws JSONException {
if (stack.isEmpty() && out.length() > 0) {
throw new JSONException("Nesting problem: multiple top-level roots");
}
beforeValue();
stack.add(empty);
out.append(openBracket);
return this;
}
代码示例来源:origin: ACRA/acra
@NonNull
public String toJSON() throws JSONException {
try {
return StringFormat.JSON.toFormattedString(this, ImmutableSet.empty(), "", "", false);
} catch (JSONException e) {
throw e;
} catch (Exception e) {
throw new JSONException(e.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!