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.
- Loading branch information
Showing
2 changed files
with
74 additions
and
1 deletion.
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
51 changes: 51 additions & 0 deletions
51
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1474.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,51 @@ | ||
package com.alibaba.json.bvt.issue_1400; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import com.alibaba.fastjson.annotation.JSONType; | ||
import junit.framework.TestCase; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Issue1474 extends TestCase { | ||
public void test_for_issue() throws Exception { | ||
Map<String,Object> extraData = new HashMap<String,Object>(); | ||
extraData.put("ext_1", null); | ||
extraData.put("ext_2", null); | ||
|
||
People p = new People(); | ||
p.setId("001"); | ||
p.setName("顾客"); | ||
p.setExtraData(extraData); | ||
|
||
assertEquals("{\"id\":\"001\",\"name\":\"顾客\"}", JSON.toJSONString(p)); | ||
} | ||
|
||
@JSONType(asm = false) | ||
static class People{ | ||
private String name; | ||
private String id; | ||
@JSONField(unwrapped=true) | ||
private Object extraData; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
public String getId() { | ||
return id; | ||
} | ||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
public Object getExtraData() { | ||
return extraData; | ||
} | ||
public void setExtraData(Object extraData) { | ||
this.extraData = extraData; | ||
} | ||
} | ||
} |