serialization

Jackson: how to prevent field serialization (while keeping deserialization)

拟墨画扇 提交于 2019-12-24 11:28:48
问题 I'd like to go further on what this question was about, I've been roaming SO for a solid hour now without finding anything. Basically, what I'm trying to do is having a property properly instanciated through Jackson internal reflection algorithm during deserialization but having this same property not serialized when it comes to serialization. I know about @JsonIgnore and @JsonIgnoreProperties but apparently I can't seem to use them right : either my property is correctly deserialized when I

F# Serialize Discriminated Union why so many bytes?

痞子三分冷 提交于 2019-12-24 11:28:28
问题 I'm trying to serialize some data for a UDP packet stream and I'm getting a huge overhead from serialization. If I encode a FileData with a 1k Byte array I get back 2312 bytes. How would I reduce this overhead without encoding and decoding everything myself? [<Serializable>] type Response = | FileSize of String * int64 | FileData of int64 * byte[] with static member Decode(packet : byte[]) = use ms = new MemoryStream(packet) let bf = new BinaryFormatter() bf.Deserialize(ms) |> unbox<Response>

Using DES to encrypt and decrypt a file in Java

回眸只為那壹抹淺笑 提交于 2019-12-24 11:27:02
问题 I'm trying to serialize an object (in this case a simple string), encrypt it, and write it to a file. The encryption seems to work, but the decryption always fails. I've tried searching around, but I can't seem to figure out what I'm doing wrong.. // Create a new key to encrypt and decrypt the file byte[] key = "password".getBytes(); // Get a cipher object in encrypt mode Cipher cipher = null; try { DESKeySpec dks = new DESKeySpec(key); SecretKeyFactory skf = SecretKeyFactory.getInstance("DES

c# serialize dictionary parameter without parent node

有些话、适合烂在心里 提交于 2019-12-24 11:00:59
问题 i have a class and wish to serialize it into xml. the class contains a dictionary.. switched it to a serializeable version (with writexml / readxml). the problem is that when the dictionary parameter gets serialized.. it wraps the dictionary elements with a parent element "Attributes" and i dont want that. Example: public class Product { public String Identifier{ get; set; } [XmlElement] public SerializableDictionary<string,string> Attributes { get; set; } //custom serializer } This Product

How can I serialize and deserialize Perl data to/from database?

三世轮回 提交于 2019-12-24 10:58:08
问题 What is the best module or approach to serialize data into a database? Currently I am looking into Storable functions freeze and thaw , example: use Storable qw(freeze thaw); use strict; my %array_test = ('Year Average' => 0.1, 'Color Average' => 0.8, 'Humans' => 0, 'Units' => 1); my $serialized_data = freeze(\%array_test); my %deserialized_data = %{ thaw($serialized_data) }; What I would like to know: Are there any native command in Perl to serialize and deserialize data? Is Storable a good

java.io.NotSerializableException: sun.nio.fs.WindowsPath - how to fix it?

和自甴很熟 提交于 2019-12-24 10:50:03
问题 I wrote a simple serialization function in order to store a fileTree representation (based on the composite pattern...), but always get following error: java.io.NotSerializableException: sun.nio.fs.WindowsPath Unfortunately I couldn't figure out so far how to fix that - anyone else encountered that? 回答1: Serialize it as a String instead of a Path. 来源: https://stackoverflow.com/questions/26011679/java-io-notserializableexception-sun-nio-fs-windowspath-how-to-fix-it

Synchronizing Jena OntModels with bnodes

瘦欲@ 提交于 2019-12-24 10:45:39
问题 This question relates to rcreswick's question on Serializing Jena OntModel Changes. I have Jena models on two (or more) machines that need to remain synchronized over sockets. The main issue that I need to address is that the models may contain anonymous nodes (bnodes), which can originate in any of the models. Question : Am I on the right track here, or is there a better, more robust approach that I'm failing to consider? I can think of 3 approaches to this problem: Serialize the complete

Changing names of properties while Serializing to JSON without source code

☆樱花仙子☆ 提交于 2019-12-24 10:35:49
问题 Need to serialize java objects to JSON while doing compression such as name change, exclusion etc. Objects use class from jar, source code of which is not available. Looked through many libraries(Jackson , Gson), but found none solving this particular problem. Most of them are annotations based, which I can't use given I don't have source code. One way to solve this problems is, use reflection and recursively go through object until you find a property name of which should be replaced or

How to change the default enums serialization in Boost.Serialization

拟墨画扇 提交于 2019-12-24 10:13:50
问题 By default in Boost.Serialization, enum types are serialized as a 32-bit integer. But I need to serialize some enum types as different width integer. I've tried to specialize the boost::serialization::serialize method, but it seems it doesn't work for enums. Here is my attempt: #include <iostream> #include <boost/archive/binary_oarchive.hpp> #include <boost/asio.hpp> enum MyEnum_t { HELLO, BYE }; namespace boost { namespace serialization { template< class Archive > void save(Archive & ar,

java.io.EOFException when trying to perform java socket operations

試著忘記壹切 提交于 2019-12-24 09:59:10
问题 I'm getting the following exception for the code included below that. This works fine when the while() loop is excluded . Why is this? Oct 6, 2011 1:19:31 AM com.mytunes.server.ServerHandler run SEVERE: null java.io.EOFException at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2552) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1297) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at com.mytunes.server.ServerHandler.run