serialization

Datacontract serialization error

醉酒当歌 提交于 2020-01-07 03:04:11
问题 This is the continuation of How to set [DataMember] on all class members So I have to serialize a class with dictionaries and other members. I have chonse the datacontext serialization that se public SimpleDataGridSample() { if (false) { MyClass theclass = new MyClass(); var serializer = new DataContractSerializer(typeof(MyClass)); using (Stream fileStream = File.Open("aaa.bin", FileMode.Create)) { XmlDictionaryWriter binaryDictionaryWriter = XmlDictionaryWriter.CreateBinaryWriter(fileStream)

Restsharp - how to serialize a list of enums to strings

孤人 提交于 2020-01-07 02:45:15
问题 I have an List<AnimalsEnum> Foo property in a class that I'm serializing to XML with RestSharp for the body of a request. I'd like the output to be: <rootNode> ... existing content... <Foo>Elephant</Foo> <Foo>Tiger</Foo> .... more content Instead, for the relevant serialisation part, I have <Foo> <AnimalsEnum /> <AnimalsEnum /> </Foo> I'd like to convert the enum values to strings and remove the container element that is automatically added. Is this possible with RestSharp? I thought it may

How to deserialize an untyped object using JSON.NET or DataContractJsonSerializer

微笑、不失礼 提交于 2020-01-07 01:21:12
问题 I'm trying to recreate an object when deserializing it. By reimplementing the Serialize and Deserialize methods so that I'll be able to use them independently. Since I'll be storing the serialized object in the database, I won't be able to access the object's type (class). The problem is: is there a way to deserialize and object without having the object's type, only it's JSON string? Any way to get it's type from the JSON string? Here are the methods: DataContractJsonSerializer public string

JMS Serializer DateTime not deserializing?

做~自己de王妃 提交于 2020-01-06 20:09:31
问题 I have a sort of special setup of Symfony2, FOSRestBundle and JMSSerializerBundle, due to a legacy DB in the background. I'm struggling to get a PUT request working, including the deserialization of a DateTime property. First things first. This is a model snippet, notice the DateTime format: /** * @var \DateTime * * @ORM\Column(name="sys_lastmodifieddate", type="datetime", nullable=true) * * @Type("DateTime<'Y-m-d\TH:i:sP'>") * * @Expose */ private $sysLastmodifieddate; I have built a Form

Android: Gson deserializes Integer as Double

喜欢而已 提交于 2020-01-06 19:57:40
问题 I am trying websockets on android using this library WebSocketRails-Android but I want to replace Jackson with Google's Gson but I am having a problem on deserialization. So on receiving a JSON string like this [["websocket_rails.subscribe",{"id":1676395261,"channel":null,"user_id":null,"data":{"message":"Connected successfully to 82c6"},"success":true,"result":null,"token":null,"server_token":null}]] Gson deserializes it and gives me the id = 1.676395261E9 I am deserializing like this

Send not serializable data to new Activity

孤者浪人 提交于 2020-01-06 18:43:52
问题 I have not serializable data which I must sent to other Activity . I try to use Intent , but it's impossible. Intent intent = new Intent(v.getContext(), UserDetailActivity.class); intent.putExtra("class", user); v.getContext().startActivity(intent); How can I send the data from previous Activity to new Activity ? 回答1: I don't think you can do this bacause the ParseUser needs to implement either Parcelable or Serializable. You probably can't modify the class so this is what you can do: Create

Best way to store serialization related info between serialization and deserialization

╄→尐↘猪︶ㄣ 提交于 2020-01-06 14:59:51
问题 I'm using serialization with DataContractSerializer and have to save e.g. object which has field of Dictionary<string, IKnownTypesProvider> where IKnownTypesProvider just know which types does it consist from. So I can easily use it to serialize existing object. But if I want to deserialize it later I have to pass a list of known types to DataContractSerializer but I can't do it because I don't know which types were used when that object was serialized. All synthetic samples from MSDN

Best way to store serialization related info between serialization and deserialization

China☆狼群 提交于 2020-01-06 14:59:24
问题 I'm using serialization with DataContractSerializer and have to save e.g. object which has field of Dictionary<string, IKnownTypesProvider> where IKnownTypesProvider just know which types does it consist from. So I can easily use it to serialize existing object. But if I want to deserialize it later I have to pass a list of known types to DataContractSerializer but I can't do it because I don't know which types were used when that object was serialized. All synthetic samples from MSDN

How do I handle an Invalid Stream header Exception: 00000001?

て烟熏妆下的殇ゞ 提交于 2020-01-06 12:50:58
问题 java.io.StreamCorruptedException: invalid stream header: 00000001 Simple Project I found this, and this seems to be a common problem. If you write to a directory with files and then manually deleted one later, you will end up getting this error. java.io.StreamCorruptedException: invalid stream header: 00000001 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:806) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299) The code: private void deserialize(File input){

Passing a web service an unknown number of parameters

不羁岁月 提交于 2020-01-06 08:59:28
问题 I'm relatively new to utilizing web services. I'm trying to create one that will be accepting data from a ASP.Net form whose input controls are created dynamically at runtime and I don't how many control values will be getting passed. I'm thinking I'll be using jQuery's serialize() on the form to get the data, but what do I have the web service accept for a parameter? I thought maybe I could use serializeArray(), but still I don't know what type of variable to accept for the JavaScript array.