package com.alibaba.json.bvt.writeAsArray;
import java.io.StringReader;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONReader;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
public class WriteAsArray_long_stream_public extends TestCase {
public void test_0 () throws Exception {
VO vo = new VO();
vo.setId(123);
vo.setName("wenshao");
String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);
Assert.assertEquals("[123,\"wenshao\"]", text);
JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
VO vo2 = reader.readObject(VO.class);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
reader.close();
}
public static class VO {
private long id;
private String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}