Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ClassLevel serializer feature config
- Loading branch information
Showing
3 changed files
with
78 additions
and
30 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
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
27 changes: 27 additions & 0 deletions
27
src/test/java/com/alibaba/json/bvt/serializer/filters/ClassLevelFeatureConfigTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
package com.alibaba.json.bvt.serializer.filters; | |||
|
|||
import org.junit.Assert; | |||
|
|||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.serializer.SerializeConfig; | |||
import com.alibaba.fastjson.serializer.SerializerFeature; | |||
|
|||
import junit.framework.TestCase; | |||
|
|||
public class ClassLevelFeatureConfigTest extends TestCase { | |||
public void test_0() throws Exception { | |||
SerializeConfig config = new SerializeConfig(); | |||
|
|||
Model model = new Model(); | |||
model.id = 1001; | |||
|
|||
Assert.assertEquals("{\"id\":1001}", JSON.toJSONString(model, config)); | |||
|
|||
config.config(Model.class, SerializerFeature.BeanToArray, true); | |||
Assert.assertEquals("[1001]", JSON.toJSONString(model, config)); | |||
} | |||
|
|||
public static class Model { | |||
public int id; | |||
} | |||
} |