package com.alibaba.json.bvt.bug; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.serializer.SerializerFeature; import junit.framework.TestCase; import org.junit.Assert; public class Bug_for_issue_572_field2 extends TestCase { public void test_for_issue() throws Exception { Model model = new Model(); model.id = 1001; model.name = "wenshao"; String text = JSON.toJSONString(model); Assert.assertEquals("{\"id\":\"1001\",\"name\":\"wenshao\"}", text); } public static class Model { @JSONField(serialzeFeatures = SerializerFeature.WriteNonStringValueAsString) public int id; public String name; } }