2014-02-27 157 views
0

我得到一个错误反序列化字节数组使用nNewtonsoft.json在c#中的byte []数组在Java(Android项目)使用Gson 。 错误是: com.google.gson.JsonSyntaxException:java.lang.IllegalStateException:预期BEGIN_ARRAY但STRING位于第1行第10列序列化字节[]与Newtonsoft.Json和反序列化到字节[]与谷歌Gson

我连载目的是

public class ServerMsg 
{ 
    public ServerCodesEnum.PdaServerAsyncCodes CommandCode { get; set; } 
    public byte[] data; 
    public List<Extra> Extras; 
    public ServerMsg() 
    { 
     Extras = new List<Extra>(); 
    } 
} 

字节[ ]导致错误。 Newtonsoft.json将数组序列化为字符串? 如何使两种类型兼容?

+0

看看这个问题http://stackoverflow.com/questions/10804489/how-to-write-a-custom-serializer-adapter-for-gson-that-i-can-use-use-net-net 。你不能指望两个不同的序列化器神奇地配合:) – Alex

回答

0

不要在服务器端使用byte []使用List,这将工作在双方。