This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
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.
bug fixed for Feature.SupportNonPublicField. for issue #1494
- Loading branch information
Showing
2 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1494.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,31 @@ | ||
package com.alibaba.json.bvt.issue_1400; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONType; | ||
import com.alibaba.fastjson.parser.Feature; | ||
import junit.framework.TestCase; | ||
|
||
public class Issue1494 extends TestCase { | ||
public void test_for_issue() throws Exception { | ||
String json = "{\"id\":1001,\"name\":\"wenshao\"}"; | ||
B b = JSON.parseObject(json, B.class); | ||
assertEquals("{\"id\":1001,\"name\":\"wenshao\"}", JSON.toJSONString(b)); | ||
} | ||
|
||
public static class A { | ||
private int id; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
} | ||
|
||
@JSONType(parseFeatures = Feature.SupportNonPublicField) | ||
public static class B extends A { | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} | ||
} |