deserialization

Serialization / Deserialization & Proguard

折月煮酒 提交于 2019-12-18 13:13:19
问题 With one of my app, I had a problem with one of my Serialized classes when I try to update my APK. Indeed, there were problems related to objects saved with the previous version of the apk and the new version of the apk. In the latest APK (in production on Android Market), I've forgot to configure my proguard.cfg for Serializable class (and so their static final long serialVersionUID member)... So when I try in my new APK to reload this previous stored Serializable class, I've a

C++: how to serialize/deserialize objects without the use of libraries?

拈花ヽ惹草 提交于 2019-12-18 11:12:31
问题 I am trying to understand how serialization/deserialization works in C++ without the use of libraries. I started with simple objects but when deserializing a vector, I found out, that I can't get the vector without having written its size first. Moreover, I don't know which file format I should choose, because, if digits exist before vector's size I can't read it right. Furthermore, I want to do that with classes and map containers. My task is to serialize/deserialize an object like this:

Why my exception class needs to be serialized?

江枫思渺然 提交于 2019-12-18 10:44:45
问题 When you extend a class with class Exception ( for creating new exception) you get a warning to have a serialVersionUID . I know that serialVersionUID plays an important role while serialization and deserialization, but when my Exception needs to be serialized? Can anyone give me a practical case in which I want my custom-exception class to have serialization and deserialization? 回答1: This is because the root class for all exceptions, Throwable implements the Serializable interface. All

serialize and deserialize enum with Gson [duplicate]

寵の児 提交于 2019-12-18 10:15:12
问题 This question already has answers here : Using Enums while parsing JSON with GSON (7 answers) Closed 4 years ago . How can i serialize and deserialize a simple enum like this with gson 2.2.4 ? public enum Color { RED, BLUE, YELLOW; } 回答1: According to Gson API documentation, Gson provides default serialization/deserialization of Enum , so basically it should be serialized and deserialized using the standard toJson and fromJson methods, as with any other type. 回答2: You can try this. import com

What is deserialize and serialize in JSON?

混江龙づ霸主 提交于 2019-12-18 09:54:13
问题 I have seen the terms "deserialize" and "serialize" with JSON. What do they mean? (I'm new in JSON. Now, I need to use JSON for my Flash ActionScript 3.0. So I found one lib for JSON) 回答1: JSON is a format that encodes objects in a string. Serialization means to convert an object into that string , and deserialization is its inverse operation (convert string -> object) . When transmitting data or storing them in a file, the data are required to be byte strings, but complex objects are seldom

How to Deserialize JSON data? C#

点点圈 提交于 2019-12-18 09:43:29
问题 Im getting a Json Data from an API and i have been trying to deserialize. Json data: { "items": [ { "id": "1", "name": "samplename", "AddressList1": { "City": "Hyd", "State": "TN", "Country": "IN" }, "Age": "10" }, { "id": "2", "name": "samplename2", "AddressList1": { "City": "Hydd", "State": "TN", "Country": "IN" }, "Age": "10" } ], "paging": { "cursors": {} } } Entities: public class AddressList1 { public string City { get; set; } public string State { get; set; } public string Country {

How to serialize a Class contains BitmapImage?

ⅰ亾dé卋堺 提交于 2019-12-18 09:34:30
问题 I have a DeepCopy method, which serializes the object passed in parameter and returns back the deserialized object to make deep copy. My method is: public static class GenericCopier<T> { public static T DeepCopy(object objectToCopy) { using (MemoryStream memoryStream = new MemoryStream()) { BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, objectToCopy); memoryStream.Seek(0, SeekOrigin.Begin); return (T)binaryFormatter.Deserialize(memoryStream);

Convert string to variable name

对着背影说爱祢 提交于 2019-12-18 07:44:58
问题 I have an XML file, I have a node and I read all ChildNodes. The name of the childNode match to a variable I have to set with the value of this childNode. In the loop, I'd like set : myvar1 to MyValue1 myvar2 to MyValue2 The C# Code : protected string myvar1; protected string myvar2; The XML content look like this : <parameters> <myvar1>MyValue1</myvar1> <myvar2>MyValue2</myvar2> </parameters> C# set variables : foreach (var item in xmlParamInstallation.SelectNodes("parameters")[0].ChildNodes

Convert string to variable name

徘徊边缘 提交于 2019-12-18 07:44:34
问题 I have an XML file, I have a node and I read all ChildNodes. The name of the childNode match to a variable I have to set with the value of this childNode. In the loop, I'd like set : myvar1 to MyValue1 myvar2 to MyValue2 The C# Code : protected string myvar1; protected string myvar2; The XML content look like this : <parameters> <myvar1>MyValue1</myvar1> <myvar2>MyValue2</myvar2> </parameters> C# set variables : foreach (var item in xmlParamInstallation.SelectNodes("parameters")[0].ChildNodes

Why when I deserialize with JSON.NET ignores my default value?

坚强是说给别人听的谎言 提交于 2019-12-18 07:41:22
问题 I'm using JSON.NET as my main serializer. This is my model, look that I've setted some JSONProperties and a DefaultValue . public class AssignmentContentItem { [JsonProperty("Id")] public string Id { get; set; } [JsonProperty("Qty")] [DefaultValue(1)] public int Quantity { get; set; } } When I serialize a List<AssignmentContentItem> , it doing a good work: private static JsonSerializerSettings s = new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore,