serialization

Handling deserialization of enum values that no longer exist

微笑、不失礼 提交于 2019-12-22 10:09:49
问题 I have an enum JJJ that has 3 values: A, B, and C. In previous versions of my program it had one additional value: D. I'd like to be able to read in the serialized objects created by previous versions of the program, but an exception is thrown when it encounters a JJJ type variable with value 'D' in the serialized object. Optimally, I'd like to be able to intercept the deserialization process and tell it to just map D's to C's when it encounters them. According to http://docs.oracle.com

How does delphi convert ModalResult properties?

我怕爱的太早我们不能终老 提交于 2019-12-22 10:01:17
问题 Hopefully this is a quick one, and "Easy if you know how"... I'm writing some kind of Serialization/Scripting class to generate forms on the fly, I tried setting a TColor the other day and got an error clBtnFace is not a valid integer value or something like that and found that the constants used in properties are registered so that they can be converted to integer, and so I added code to fetch the converter and use it. Now today I have a similar issue with the ModalResult property but I can

Are Hashtables Serializable?

[亡魂溺海] 提交于 2019-12-22 09:58:13
问题 I see a pervasive belief (2009 article) throughout the internet that the Hashtable class is not serializable; however, I cannot find any modern documentation that supports this notion. The belief stems from another ill-documented belief that the IDictionary interface prevents serialization; however, I cannot find anything in MSDN that supports this claim, today. Further, Hashtable implements ISerializable and contains extension methods that accept serialization information. So, what's the

Resolving Circular References for Objects Implementing ISerializable

随声附和 提交于 2019-12-22 09:57:15
问题 I'm writing my own IFormatter implementation and I cannot think of a way to resolve circular references between two types that both implement ISerializable. Here's the usual pattern: [Serializable] class Foo : ISerializable { private Bar m_bar; public Foo(Bar bar) { m_bar = bar; m_bar.Foo = this; } public Bar Bar { get { return m_bar; } } protected Foo(SerializationInfo info, StreamingContext context) { m_bar = (Bar)info.GetValue("1", typeof(Bar)); } public void GetObjectData

Serialize Set of UUID using Jackson

不打扰是莪最后的温柔 提交于 2019-12-22 09:49:50
问题 I found that jackson comes equipped with a UUID serizlizer/deserializer that can be used like this: @Data @NoArgsConstructor public class MyClass { @JsonSerialize(using=UUIDSerializer.class) @JsonDeserialize(using=UUDIDeserializer.class) private UUID myUUID; } And then using ObjectMapper on MyClass will correctly serialize/deserialize the myUUID field. However, my class has a set of UUIDs that I want to serialize. I tried annotating the field the same way as above, but it complains that Set

Serialized objects disappearing (BinaryFormatter)

强颜欢笑 提交于 2019-12-22 09:31:04
问题 Background I have an object which I need to serialize in order to transfer to a high performance computing cluster for later use Previously, I've used the out-of-the-box binary formatter for my object which represents a statistical shape model and all worked happily My object became more complex and I decided to customize the serialization process by implementing ISerializable. I continue to support data stored in the previous format The Problem My problem is that one particular value appears

How to serialize an object in C# and prevent tampering?

余生长醉 提交于 2019-12-22 09:24:30
问题 I have a C# class as follows: public class TestObj { private int intval; private string stringval; private int[] intarray; private string[] stringarray; //... public properties not shown here } I would like to serialize an instance of this class into a string. In addition: I will be appending this string as a QueryString param to a URL. So I would like to take some effort to ensure that the string cannot be tampered with easily. Also, I would like the serialization method to be efficient so

Asymmetric serialization and deserialization using Jackson

江枫思渺然 提交于 2019-12-22 09:16:52
问题 I am using Jackson to serialize and deserialize data for a RESTful API. I'd like to have a REST resource ( /comments ) that allows to POST comments as well as to GET a list of comments. Here's a (simplified) example of what gets posted to /comments . {"text":"Text","author":"Paul","email":"paul@example.org"} Here's what the result of GET /comments should look like: [{"text":"Text","author":"Paul","emailHash":"76w0kjKP9HpsdhBjx895Sg=="}] Since email addresses shouldn't be visible to anyone, I

Serializing C++ objects

纵然是瞬间 提交于 2019-12-22 09:13:31
问题 I would like to implement a Serialization Class which takes in an object and converts it into a binary stream and stored in a file. Later, the object should be reconstructed from a file. Though this functionality is provided by BinaryFormatter in C#, I would like to design my own Serialization class from scratch. Can someone point to some resources ? Thanks in advance 回答1: I have been using boost::serialization library for a while now and I think it is very good. You just need to create the

Can not find a deserializer for non-concrete Map type [map type; class javax.ws.rs.core.MultivaluedMap

这一生的挚爱 提交于 2019-12-22 08:59:44
问题 I'm having the following issue in Deserialization with org.codehaus.jackson.map.ObjectMapper that does not work for the following class. I'm not sure what is going wrong with the MultivaluedMap I'm using. public class ClassD { private ClassA objA; private ClassB objB; private final ClassC objC; private MultivaluedMap<String, String> headerMap; } public static void main(String[] args) { String fileName = "someFilePath"; mockCollection = fromJSON(new TypeReference<Collection<ClassD>>() {}, new