本文整理汇总了Java中com.alibaba.fastjson.serializer.SerializeWriter.writeFieldValue方法的典型用法代码示例。如果您正苦于以下问题:Java SerializeWriter.writeFieldValue方法的具体用法?Java SerializeWriter.writeFieldValue怎么用?Java SerializeWriter.writeFieldValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.serializer.SerializeWriter
的用法示例。
在下文中一共展示了SerializeWriter.writeFieldValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType,
int features) throws IOException {
Image image = (Image) object;
SerializeWriter out = serializer.out;
out.writeFieldValue('{', "height", image.getHeight());
out.writeFieldValueStringWithDoubleQuote(',', "size", image.getSize().name());
String tile = image.getTitle();
out.writeFieldValueStringWithDoubleQuoteCheck(',', "title", tile);
out.writeFieldValueStringWithDoubleQuoteCheck(',', "uri", image.getUri());
out.writeFieldValue(',', "width", image.getWidth());
out.write('}');
// TODO
}
示例2: write
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType,
int features) throws IOException {
Model model = (Model) object;
SerializeWriter out = serializer.getWriter();
out.writeFieldValue('{', "ID", model.id);
out.write('}');
}
示例3: test_0
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
Assert.assertEquals(10, writer.getBufferLength());
writer.writeFieldValue(',', "abcde01245abcde", true);
writer.close();
String text = out.toString();
Assert.assertEquals(",abcde01245abcde:true", text);
}
示例4: test_0
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
writer.config(SerializerFeature.QuoteFieldNames, true);
Assert.assertEquals(10, writer.getBufferLength());
writer.writeFieldValue(',', "abcde01245abcde", 123L);
writer.close();
String text = out.toString();
Assert.assertEquals(",\"abcde01245abcde\":123", text);
}
示例5: test_0
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
writer.config(SerializerFeature.QuoteFieldNames, true);
Assert.assertEquals(10, writer.getBufferLength());
writer.writeFieldValue(',', "abcde01245abcde", "123");
writer.close();
String text = out.toString();
Assert.assertEquals(",\"abcde01245abcde\":\"123\"", text);
}
示例6: test_0
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
writer.config(SerializerFeature.QuoteFieldNames, true);
Assert.assertEquals(10, writer.getBufferLength());
writer.writeFieldValue(',', "abcde01245abcde", 123);
writer.close();
String text = out.toString();
Assert.assertEquals(",\"abcde01245abcde\":123", text);
}
示例7: test_0
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
writer.config(SerializerFeature.QuoteFieldNames, true);
writer.config(SerializerFeature.UseSingleQuotes, true);
Assert.assertEquals(10, writer.getBufferLength());
writer.writeFieldValue(',', "abcde01245abcde", "123");
writer.close();
String text = out.toString();
Assert.assertEquals(",'abcde01245abcde':'123'", text);
}
示例8: test_0
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
Assert.assertEquals(10, writer.getBufferLength());
writer.writeFieldValue(',', "abcde01245abcde", 123);
writer.close();
String text = out.toString();
Assert.assertEquals(",abcde01245abcde:123", text);
}
示例9: test_0
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
Assert.assertEquals(10, writer.getBufferLength());
writer.config(SerializerFeature.QuoteFieldNames, true);
writer.writeFieldValue(',', "abcde01245abcde", true);
writer.close();
String text = out.toString();
Assert.assertEquals(",\"abcde01245abcde\":true", text);
}
示例10: test_3
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_3() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeFieldValue(',', "name", (String) null);
Assert.assertEquals(",'name':null", out.toString());
}
示例11: test_4
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_4() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeFieldValue(',', "name", (String) null);
Assert.assertEquals(",'name':null", out.toString());
}
示例12: test_0
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, true);
out.writeFieldValue(',', "name", "\t");
Assert.assertEquals(",\"name\":\"\\t\"", out.toString());
out.close();
}
示例13: test_1
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, true);
out.writeFieldValue(',', "name", "\t\n");
Assert.assertEquals(",\"name\":\"\\t\\n\"", out.toString());
out.close();
}
示例14: test_4
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_4() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, false);
out.writeFieldValue(',', "name", "\t\n \b\n\r\f\\ \"");
Assert.assertEquals(",\"name\":\"\\t\\n \\b\\n\\r\\f\\\\ \\\"\"", out.toString());
out.close();
}
示例15: test_null_1
import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_null_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, false);
out.writeFieldValue(',', "name", (String) null);
Assert.assertEquals(",name:null", out.toString());
}