|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
org.less4j.JSON.Error
public static class JSON.Error
A simple JSON exception throwed for any syntax error found by the interpreter.
String string = "{\"test\": fail}";
try {
Object value = (new JSON()).eval(string)
} catch (JSON.Error e) {
System.out.println(e.jstr());
}
Copyright © 2006 Laurent A.V. Szyster
| Field Summary | |
|---|---|
int |
jsonIndex
The position of the JSON syntax error, -1 by default. |
java.util.ArrayList |
jsonPath
The path to the JSON error value, if any. |
| Constructor Summary | |
|---|---|
JSON.Error(java.lang.String message)
Instanciate a JSON error with an error message. |
|
JSON.Error(java.lang.String message,
int index)
Instanciate a JSON error with an error message and the index in the JSON string at which the error occured. |
|
| Method Summary | |
|---|---|
java.lang.StringBuffer |
strb(java.lang.StringBuffer sb)
Buffers the JSON representation of a JSON.Error. |
java.lang.String |
toJSONString()
Represents a JSON error as a JSON array with three elements: the error message, the character index where the error occurred and the path in the object model. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Throwable |
|---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public int jsonIndex
public java.util.ArrayList jsonPath
| Constructor Detail |
|---|
public JSON.Error(java.lang.String message)
message - the error message
public JSON.Error(java.lang.String message,
int index)
message - the error messageindex - position at which the error occured| Method Detail |
|---|
public java.lang.StringBuffer strb(java.lang.StringBuffer sb)
JSON.Error.
...
StringBuffer sb = new StringBuffer();
try {
String model = (new JSON()).eval("{fail}");
} catch (JSONR.Error e) {
e.jsonError(sb);
}
System.out.println(sb.toString());
...
public java.lang.String toJSONString()
Represents a JSON error as a JSON array with three elements: the error message, the character index where the error occurred and the path in the object model.
...
...["error message", 23, ["list", 2]]
public java.lang.String toString()
toString in class java.lang.Throwable
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||