-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_184.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.alibaba.json.bvt.bug; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.serializer.SerializeConfig; | ||
import com.alibaba.fastjson.serializer.SerializerFeature; | ||
|
||
import junit.framework.TestCase; | ||
|
||
public class Bug_for_issue_184 extends TestCase { | ||
|
||
public void test_for_issue() throws Exception { | ||
TUser user = new TUser(); | ||
user.id = 1001; | ||
// 禁用asm(在android下使用),启用asm则没问题。 | ||
SerializeConfig.getGlobalInstance().setAsmEnable(false); | ||
String json = JSON.toJSONString(user, SerializerFeature.WriteClassName); | ||
// 输出{"@type":"xx.TUser","id":0L} | ||
System.out.println(json); | ||
// 下面反系列化错误:com.alibaba.fastjson.JSONException: unclosed.str | ||
// 原因:id带L后缀 | ||
user = (TUser) JSON.parse(json); | ||
} | ||
|
||
public static class TUser { | ||
|
||
public long id; | ||
} | ||
} |