public final void scanTrue() {
if (this.ch != 't') {
throw new JSONException("error parse true");
}
next();
if (this.ch != 'r') {
throw new JSONException("error parse true");
}
next();
if (this.ch != 'u') {
throw new JSONException("error parse true");
}
next();
if (this.ch != 'e') {
throw new JSONException("error parse true");
}
next();
if (this.ch == ' ' || this.ch == ',' || this.ch == '}' || this.ch == ']' || this.ch == '\n' || this.ch == '\r' || this.ch == '\t' || this.ch == '\u001a' || this.ch == '\f' || this.ch == '\b') {
this.token = 6;
return;
}
throw new JSONException("scan true error");
}
java类com.alibaba.fastjson.JSONException的实例源码
JSONLexerBase.java 文件源码
项目:boohee_v5.6
阅读 31
收藏 0
点赞 0
评论 0
DeserializeBeanInfo.java 文件源码
项目:boohee_v5.6
阅读 38
收藏 0
点赞 0
评论 0
public static Constructor<?> getCreatorConstructor(Class<?> clazz) {
Constructor[] declaredConstructors = clazz.getDeclaredConstructors();
int length = declaredConstructors.length;
int i = 0;
while (i < length) {
Constructor<?> constructor = declaredConstructors[i];
if (((JSONCreator) constructor.getAnnotation(JSONCreator.class)) == null) {
i++;
} else if (null == null) {
return constructor;
} else {
throw new JSONException("multi-json creator");
}
}
return null;
}
FastJsonProvider.java 文件源码
项目:GitHub
阅读 29
收藏 0
点赞 0
评论 0
/**
* Method that JAX-RS container calls to deserialize given value.
*/
public Object readFrom(Class<Object> type, //
Type genericType, //
Annotation[] annotations, //
MediaType mediaType, //
MultivaluedMap<String, String> httpHeaders, //
InputStream entityStream) throws IOException, WebApplicationException {
try {
FastJsonConfig fastJsonConfig = locateConfigProvider(type, mediaType);
return JSON.parseObject(entityStream, fastJsonConfig.getCharset(), genericType, fastJsonConfig.getFeatures());
} catch (JSONException ex) {
throw new WebApplicationException("JSON parse error: " + ex.getMessage(), ex);
}
}
DenyTest.java 文件源码
项目:GitHub
阅读 37
收藏 0
点赞 0
评论 0
public void test_0() throws Exception {
String text = "{}";
ParserConfig config = new ParserConfig();
config.addDeny(null);
config.addDeny("com.alibaba.json.bvtVO.deny");
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvtVO.deny$A\"}", Object.class, config, JSON.DEFAULT_PARSER_FEATURE);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
JSON.parseObject(text, B.class, config, JSON.DEFAULT_PARSER_FEATURE);
}
JavaBeanDeserializer.java 文件源码
项目:uavstack
阅读 30
收藏 0
点赞 0
评论 0
void parseExtra(DefaultJSONParser parser, Object object, String key) {
final JSONLexer lexer = parser.getLexer(); // xxx
if (!lexer.isEnabled(Feature.IgnoreNotMatch)) {
throw new JSONException("setter not found, class " + clazz.getName() + ", property " + key);
}
lexer.nextTokenWithColon();
Type type = FilterUtils.getExtratype(parser, object, key);
Object value;
if (type == null) {
value = parser.parse(); // skip
} else {
value = parser.parseObject(type);
}
FilterUtils.processExtra(parser, object, key, value);
}
JavaBeanInfo.java 文件源码
项目:GitHub
阅读 41
收藏 0
点赞 0
评论 0
private static Method getFactoryMethod(Class<?> clazz, Method[] methods) {
Method factoryMethod = null;
for (Method method : methods) {
if (!Modifier.isStatic(method.getModifiers())) {
continue;
}
if (!clazz.isAssignableFrom(method.getReturnType())) {
continue;
}
JSONCreator annotation = method.getAnnotation(JSONCreator.class);
if (annotation != null) {
if (factoryMethod != null) {
throw new JSONException("multi-JSONCreator");
}
factoryMethod = method;
// 不应该break,否则多个静态工厂方法上存在 JSONCreator 注解时,并不会触发上述异常抛出
}
}
return factoryMethod;
}
WeiBoUserMgm.java 文件源码
项目:zhkuas_ssm_maven
阅读 31
收藏 0
点赞 0
评论 0
public AccessToken getAccessTokenByCode(String code) throws WeiboException, JSONException{
Map<String,String> params =new HashMap<String,String>();
params.put("client_id", WebConfigUtils.getValue("client_ID"));
params.put("client_secret", WebConfigUtils.getValue("client_SERCRET"));
params.put("grant_type", "authorization_code");
params.put("code",code);
params.put("redirect_uri", new StringBuilder().append(WebConfigUtils.getValue("rz_host")).append("/").append(WebConfigUtils.getValue("redirect_URI")).toString());
fetchUrl.setPostData(params);
String res = null;
try {
res = fetchUrl.post(WebConfigUtils.getValue("accessTokenURL"),Constants.MAX_FETCHURL_COUNT);
} catch (FetchTimeoutException e) {
// e.printStackTrace();
logger.info(e.getMessage());
}
// String res =new HttpClientUtils().sendPostSSLRequest(WebConfigUtils.getValue("accessTokenURL"), params);
return new AccessToken(res);
}
TypeUtils.java 文件源码
项目:uavstack
阅读 37
收藏 0
点赞 0
评论 0
public static final Character castToChar(Object value) {
if (value == null) {
return null;
}
if (value instanceof Character) {
return (Character) value;
}
if (value instanceof String) {
String strVal = (String) value;
if (strVal.length() == 0) {
return null;
}
if (strVal.length() != 1) {
throw new JSONException("can not cast to byte, value : " + value);
}
return strVal.charAt(0);
}
throw new JSONException("can not cast to byte, value : " + value);
}
ImageDeserializer.java 文件源码
项目:GitHub
阅读 31
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
Image image = new Image();
final JSONLexer lexer = parser.getLexer();
if (lexer.token() != JSONToken.LBRACKET) {
throw new JSONException("error");
}
int height = lexer.scanInt(',');
int width = lexer.scanInt(',');
String sizeName = lexer.scanSymbolWithSeperator(parser.getSymbolTable(), ',');
String title = lexer.scanString(',');
String uri = lexer.scanString(']');
lexer.nextToken(JSONToken.COMMA);
image.setHeight(height);
image.setWidth(width);
image.setSize(Size.valueOf(sizeName));
image.setTitle(title);
image.setUri(uri);
return (T) image;
}
SealUserInfoManager.java 文件源码
项目:sealtalk-android-master
阅读 44
收藏 0
点赞 0
评论 0
private boolean fetchGroups() throws HttpException {
GetGroupResponse groupResponse;
try {
groupResponse = action.getGroups();
} catch (JSONException e) {
NLog.d(TAG, "fetchGroups occurs JSONException e=" + e.toString());
return true;
}
if (groupResponse != null && groupResponse.getCode() == 200) {
List<GetGroupResponse.ResultEntity> groupsList = groupResponse.getResult();
if (groupsList != null && groupsList.size() > 0) {
syncDeleteGroups();
addGroups(groupsList);
}
mGetAllUserInfoState |= GROUPS;
return true;
}
return false;
}
DeserializeBeanInfo.java 文件源码
项目:uavstack
阅读 32
收藏 0
点赞 0
评论 0
public static Constructor<?> getCreatorConstructor(Class<?> clazz) {
Constructor<?> creatorConstructor = null;
for (Constructor<?> constructor : clazz.getDeclaredConstructors()) {
JSONCreator annotation = constructor.getAnnotation(JSONCreator.class);
if (annotation != null) {
if (creatorConstructor != null) {
throw new JSONException("multi-json creator");
}
creatorConstructor = constructor;
break;
}
}
return creatorConstructor;
}
ClassDerializer.java 文件源码
项目:uavstack
阅读 42
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.getLexer();
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken();
return null;
}
if (lexer.token() != JSONToken.LITERAL_STRING) {
throw new JSONException("expect className");
}
String className = lexer.stringVal();
lexer.nextToken(JSONToken.COMMA);
return (T) TypeUtils.loadClass(className);
}
SealUserInfoManager.java 文件源码
项目:rongyunDemo
阅读 38
收藏 0
点赞 0
评论 0
private boolean fetchGroups() throws HttpException {
GetGroupResponse groupResponse;
try {
groupResponse = action.getGroups();
} catch (JSONException e) {
NLog.d(TAG, "fetchGroups occurs JSONException e=" + e.toString());
return true;
}
if (groupResponse != null && groupResponse.getCode() == 200) {
List<GetGroupResponse.ResultEntity> groupsList = groupResponse.getResult();
if (groupsList != null && groupsList.size() > 0) {
syncDeleteGroups();
addGroups(groupsList);
}
mGetAllUserInfoState |= GROUPS;
return true;
}
return false;
}
BugTest0.java 文件源码
项目:GitHub
阅读 37
收藏 0
点赞 0
评论 0
public void test_error_0() throws Exception {
Exception error = null;
try {
JSON.parseObject("\"222A\"", Timestamp.class);
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
ColorDeserializerTest.java 文件源码
项目:GitHub
阅读 34
收藏 0
点赞 0
评论 0
public void test_error_3() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"x\":44}", Color.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Issue1330_byte.java 文件源码
项目:GitHub
阅读 32
收藏 0
点赞 0
评论 0
public void test_for_issue() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
} catch (JSONException e) {
error = e;
}
assertNotNull(error);
assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
}
JSONScannerTest_false.java 文件源码
项目:GitHub
阅读 31
收藏 0
点赞 0
评论 0
public void test_scan_false_1() throws Exception {
JSONException error = null;
try {
JSONScanner lexer = new JSONScanner("zalse");
lexer.scanFalse();
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
FanmeiResponse.java 文件源码
项目:pay4j
阅读 27
收藏 0
点赞 0
评论 0
public <T> T getAsObject(Class<T> clazz) {
String content = getContent();
String contentType = getContentType();
if (null == content || null == contentType) {
return null;
}
if (contentType.contains(ContentType.APPLICATION_JSON.getMimeType())) {
return JSON.parseObject(content, clazz);
}
if (contentType.contains(ContentType.APPLICATION_XML.getMimeType())
|| contentType.contains(ContentType.TEXT_XML.getMimeType())) {
return XmlStream.fromXML(content, clazz);
} else if (contentType.contains(ContentType.TEXT_PLAIN.getMimeType())
|| contentType.contains(ContentType.TEXT_HTML.getMimeType())) {
try {
return JSON.parseObject(content, clazz);
} catch (JSONException e) {
}
try {
return XmlStream.fromXML(content, clazz);
} catch (IllegalArgumentException ex) {
}
throw WeixinException.of(content);
}
return null;
}
JSONPath_array_put.java 文件源码
项目:GitHub
阅读 34
收藏 0
点赞 0
评论 0
public void test_put_array_error_1() throws Exception {
Exception error = null;
try {
JSONPath path = new JSONPath("$.values");
path.arrayAdd(Collections.singletonMap("values", new Object()), 123);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
DefaultJSONParser.java 文件源码
项目:uavstack
阅读 29
收藏 0
点赞 0
评论 0
public final void accept(final int token, int nextExpectToken) {
final JSONLexer lexer = getLexer();
if (lexer.token() == token) {
lexer.nextToken(nextExpectToken);
} else {
throw new JSONException("syntax error, expect " + JSONToken.name(token) + ", actual "
+ JSONToken.name(lexer.token()));
}
}
StackTraceElementDeserializerTest.java 文件源码
项目:GitHub
阅读 32
收藏 0
点赞 0
评论 0
public void test_stack_error_10() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"lineNumber\":true}", StackTraceElement.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
JSONScannerTest_false.java 文件源码
项目:GitHub
阅读 29
收藏 0
点赞 0
评论 0
public void test_scan_false_4() throws Exception {
JSONException error = null;
try {
JSONScanner lexer = new JSONScanner("falze");
lexer.scanFalse();
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
JSONScannerTest_true.java 文件源码
项目:GitHub
阅读 28
收藏 0
点赞 0
评论 0
public void test_scan_true_5() throws Exception {
JSONException error = null;
try {
JSONScanner lexer = new JSONScanner("truee");
lexer.scanTrue();
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
DefaultExtJSONParserTest_0.java 文件源码
项目:GitHub
阅读 66
收藏 0
点赞 0
评论 0
public void test_error_4() throws Exception {
JSONException error = null;
try {
DefaultJSONParser parser = new DefaultJSONParser(
"[\"age\":33}");
parser.parseObject(new User());
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
DateTest_error.java 文件源码
项目:GitHub
阅读 45
收藏 0
点赞 0
评论 0
public void test_error_4() throws Exception {
String text = "{\"@type\":\"java.util.Date\",1:true}";
Exception error = null;
try {
JSON.parseObject(text);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
ListStringFieldTest_dom.java 文件源码
项目:GitHub
阅读 27
收藏 0
点赞 0
评论 0
public void test_error_2() throws Exception {
String text = "{\"model\":{\"values\":[][";
Exception error = null;
try {
JSON.parseObject(text, new TypeReference<Map<String, Model>>() {
});
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
DateTest_error.java 文件源码
项目:GitHub
阅读 29
收藏 0
点赞 0
评论 0
public void test_error_2() throws Exception {
String text = "{\"@type\":\"java.util.Date\",\"value\":true}";
Exception error = null;
try {
JSON.parseObject(text, Date.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
ColorDeserializerTest.java 文件源码
项目:GitHub
阅读 25
收藏 0
点赞 0
评论 0
public void test_error_2() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"r\":44.}", Color.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
UserItemManager.java 文件源码
项目:TPondof
阅读 28
收藏 0
点赞 0
评论 0
public static User getUserInfo (int uid, JSONObject object, boolean loadFull) throws APIException {
if (mCachedUsers.containsKey(uid)) {
// TODO: 这里会缓存 简短的用户信息 ,当获取完整信息时也会取出缓存。
return mCachedUsers.get(uid);
}
try {
JSONObject data = object.getJSONObject("data");
User user = new User();
user.setId(uid);
JSONObject attributes;
if (loadFull) {
attributes = data.getJSONObject("attributes");
} else {
attributes = object.getJSONObject("attributes");
}
user.setUsername(attributes.getString("username"));
user.setAvatarUrl(attributes.getString("avatarUrl"));
if (loadFull) {
user.setBio(attributes.getString("bio"));
user.setJoinTime(attributes.getString("joinTime"));
user.setDiscussionsCount(attributes.getInteger("discussionsCount"));
user.setCommentsCount(attributes.getInteger("commentsCount"));
user.setCanEdit(attributes.getBoolean("canEdit"));
user.setCanDelete(attributes.getBoolean("canDelete"));
user.setCanSuspend(attributes.getBoolean("canSuspend"));
user.setVingleShareSocial(attributes.getString("vingle.share.social"));
//TODO:Group
}
mCachedUsers.put(uid, user);
return user;
} catch (JSONException e) {
throw new APIException(e);
}
}
SOAResParseUtil.java 文件源码
项目:asura
阅读 33
收藏 0
点赞 0
评论 0
/**
* 获取返回的JSON对象
*
* @param result
* @return
* @author xuxiao
* @created 2014年5月7日 下午5:59:58
*/
public static JSONObject getJsonObj(final String result) {
try {
return JSON.parseObject(result);
} catch (final JSONException e) {
LOGGER.error("解析SOA返回JSON结果错误!", e);
return null;
}
}