serialization

Does BinaryFormatter apply any compression?

丶灬走出姿态 提交于 2020-01-13 09:04:51
问题 When .NET's BinaryFormatter is used to serialize an object graph, is any type of compression applied? I ask in the context of whether I should worry about the object graph having many repeated strings and integers. Edit - Hold on, if strings are interned in .NET, there's no need to worry about repeated strings, right? 回答1: No, it doesn't provide any compression but you can compress the output yourself using the GZipStream type. Edit: Mehrdad has a wonderful example of this technique in his

Does BinaryFormatter apply any compression?

冷暖自知 提交于 2020-01-13 09:04:28
问题 When .NET's BinaryFormatter is used to serialize an object graph, is any type of compression applied? I ask in the context of whether I should worry about the object graph having many repeated strings and integers. Edit - Hold on, if strings are interned in .NET, there's no need to worry about repeated strings, right? 回答1: No, it doesn't provide any compression but you can compress the output yourself using the GZipStream type. Edit: Mehrdad has a wonderful example of this technique in his

Library for saving c++ objects to database

核能气质少年 提交于 2020-01-13 06:06:49
问题 I am currently saving my object graph in xml file with boost serialization. The library is great, it automatically restores the objects and all member pointers and references. Problem : I need to have random access to the data ( read just one object, or delete just one object ). With boost serialization the scenario is like this : --load all objects from file -- use and modify objects -- write all objects to archive again The drawback with this is if only one object changed , I want to write

ProtoBuf-Net error message “ Invalid field in source data: 0”

我是研究僧i 提交于 2020-01-13 05:45:41
问题 I succeed in serializing instances of the following class but when I try to deserialize right after I get the following error message: " Invalid field in source data: 0" . I have no clue what it refers to because I find below class straight forward. I just updated protobuf-net version to 2.00.614 (runtime version: 2.0.50727). Any idea whether I am possibly overlooking something trivial? [ProtoContract] public class TimeSeriesProperties { [ProtoMember(1)] public string TimeSeriesName { get;

How to deserialize byte[] into generic object to be cast at method call

半世苍凉 提交于 2020-01-12 22:27:16
问题 I am working on an object encryption class. I have everything worked out but I want to be able to encrypt/decrypt any object type with one deserialize method. As of now the only thing holding me up is the deserialize method. I have the function returning type(object) in the hopes of returning a weak typed object. It works as long as I cast the type during the return value assignment, but If I deserialize into type 'object' the result is byte[]. This means that I have to write a deserialize

Serializing an object to JSON, XML, YAML?

喜欢而已 提交于 2020-01-12 18:47:48
问题 I asked a previous question about serialization and validation. Someone mentioned using the JSON gem which allows me to tell my object how to serialize with the to_json method, however Ruby seems to do LOTS of complicated things really easily, however on the flip side some really simple things seem to be quite complicated, Serialization being one of those things. I want to find out if there is a way to have a clean object: class CleanClass attr_accessor :variable1 attr_accessor :variable2

Setting Jackson feature WRITE_DATES_AS_TIMESTAMPS not working in Spring Boot

让人想犯罪 __ 提交于 2020-01-12 16:23:35
问题 I set spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false in the Spring Boot config but the Jackson serializer still produces [1942,4,2] instead of "1942-04-02" for a DateTime value. Some debugging snapshots In org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration.Jackson2ObjectMapperBuilderCustomizerConfiguration.StandardJackson2ObjectMapperBuilderCustomizer#customize there's configureFeatures(builder, this.jacksonProperties.getSerialization()); which shows that

Setting Jackson feature WRITE_DATES_AS_TIMESTAMPS not working in Spring Boot

空扰寡人 提交于 2020-01-12 16:21:47
问题 I set spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false in the Spring Boot config but the Jackson serializer still produces [1942,4,2] instead of "1942-04-02" for a DateTime value. Some debugging snapshots In org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration.Jackson2ObjectMapperBuilderCustomizerConfiguration.StandardJackson2ObjectMapperBuilderCustomizer#customize there's configureFeatures(builder, this.jacksonProperties.getSerialization()); which shows that

C# serialize decimal to xml

谁说胖子不能爱 提交于 2020-01-12 11:41:12
问题 I got a decimal property, like [XmlElementAttribute(DataType = "decimal")] decimal Price The problem is that I wanna force it to serialize always with precision of 2, but if the price is 10.50 it will be serialized to XML like <Price>10.5</Price> . Theres any way to force it (without creating a new property or changing the get of this property? I'm looking for some way to do this only sending a pattern to the XmlSerializer (or the XmlElementAttribute) or any smart way to do this ? Thanks 回答1:

C# serialize decimal to xml

流过昼夜 提交于 2020-01-12 11:39:37
问题 I got a decimal property, like [XmlElementAttribute(DataType = "decimal")] decimal Price The problem is that I wanna force it to serialize always with precision of 2, but if the price is 10.50 it will be serialized to XML like <Price>10.5</Price> . Theres any way to force it (without creating a new property or changing the get of this property? I'm looking for some way to do this only sending a pattern to the XmlSerializer (or the XmlElementAttribute) or any smart way to do this ? Thanks 回答1: