serialization

How to serialize a list in AutoBean (GWT)?

拜拜、爱过 提交于 2019-12-22 05:23:41
问题 I'm trying to figure out how to serialize a list using AutoBean in GWT, but I keep getting a Null Pointer Exception. Here's what I have: GuideCreatorFactory beanFactory = AutoBeanFactorySource.create(GuideCreatorFactory.class); List<Guide> guides = new LinkedList<Guide>(); Guide guide = new Guide(); guide.setText("this is the text"); guide.setTitle("this is the title"); guides.add(guide); GuideCreatorList<Guide> impl = new GuideCreatorListImpl(); impl.setGuides(guides); System.out.println(

Custom serialize_handler for custom php SessionHandler (DB storage)

为君一笑 提交于 2019-12-22 05:23:08
问题 In the process of using 3rd party (django) session management within php, i need to have custom serialization functions in order to encode/decode it properly to fit django's salted storage of session data. Currently, it appears that the ini setting session.serialize_handler can either be php or wddx. Is there any way to set up a custom serialize_handler as a class? I'd like to have something like this: class CustomSessionSerializer { public static function serialize($data){ // Serializes raw

Is there a way to tell if an object has implemented ToString explicitly in c#

梦想的初衷 提交于 2019-12-22 05:20:05
问题 I am trying to log information about the state of some objects and classes in my code. Not all the classes or libraries were implemented with Serialization. So I am using Reflection on the Properties to write out an XML document of the state. However, I have a challenge in that some objects like builtin Classes (ie Strings, DateTime, Numbers etc...) have a ToString function that prints out the value of the class in a meaningful way. But for other classes, calling ToString just uses the

Serialize/Deserialize two-dimensional array

不羁岁月 提交于 2019-12-22 05:16:16
问题 For some reason my previous question was considered too vague. So let me be more specific. I have a 2 dimensional array of type single. I want to serialize it to save in an Access database. The suggestion was to save it as a Memo field which is fine. I want to later read the Memo field and deserialize it to retrieve the original array. I have searched extensively on the web and here and can not find the answer. I believe I am serializing the array correctly but do not know how to deserialize

Can OnDeserializedAttribute be used instead of IDeserializationCallback interface?

不打扰是莪最后的温柔 提交于 2019-12-22 05:07:29
问题 As MSDN states here, it can. But I've spent 2 hours digging mscorlib code, because in some cases the BinaryFormatter called my method marked with OnDeserialized BEFORE deserialization constructor. That is, the order was OnDeserializing(StreamingContext context) OnDeserialized(StreamingContext context) .ctor(SerializationInfo info, StreamingContext context) While I was expecting it to be OnDeserializing(StreamingContext context) .ctor(SerializationInfo info, StreamingContext context)

Shall I use POJO or JSONObject for REST calls

安稳与你 提交于 2019-12-22 05:07:26
问题 Recently I have stumbled upon a situation where my new team is heavily using JsonObject for doing rest data interchange. Their view is while using pojo we are binding tightly with the rest service, while jsonObject gives freedom. Also it saves from unnecessary data serialisation at the same time reducing number of classes heavily. I have some points to encounter them as: Pojo gives more meaning to data and we are holding data with correct data type. If we need only 2 fields of 10 fields of

Shall I use POJO or JSONObject for REST calls

风流意气都作罢 提交于 2019-12-22 05:07:17
问题 Recently I have stumbled upon a situation where my new team is heavily using JsonObject for doing rest data interchange. Their view is while using pojo we are binding tightly with the rest service, while jsonObject gives freedom. Also it saves from unnecessary data serialisation at the same time reducing number of classes heavily. I have some points to encounter them as: Pojo gives more meaning to data and we are holding data with correct data type. If we need only 2 fields of 10 fields of

Can OnDeserializedAttribute be used instead of IDeserializationCallback interface?

泄露秘密 提交于 2019-12-22 05:07:08
问题 As MSDN states here, it can. But I've spent 2 hours digging mscorlib code, because in some cases the BinaryFormatter called my method marked with OnDeserialized BEFORE deserialization constructor. That is, the order was OnDeserializing(StreamingContext context) OnDeserialized(StreamingContext context) .ctor(SerializationInfo info, StreamingContext context) While I was expecting it to be OnDeserializing(StreamingContext context) .ctor(SerializationInfo info, StreamingContext context)

Ruby serialize struct with JSON

随声附和 提交于 2019-12-22 05:06:14
问题 I am trying to serialize a simple struct to JSON which works fine, but I can't get it to create an instance of that struct from the JSON. Here is how I am trying to do it. require 'rubygems' require 'json' Person = Struct.new(:name, :age) json = Person.new('Adam', 19).to_json puts json me = JSON.load(json) puts me.name And I get the following output: "#<struct Person name=\"Adam\", age=19>" /usr/lib/ruby/1.9.1/json/common.rb:148:in `parse': 746: unexpected token at '"#<struct Person name=\

serialize any data type as vector<uint8_t> - use reinterpret_cast?

我的梦境 提交于 2019-12-22 04:56:07
问题 I didnt find anything directly related in searching, so please forgive if this is a duplicate. What I am looking to do is serialize data across a network connection. My approach is to convert everything I need to transfer to a std::vector< uint8_t > and on the receiving side unpack the data into the appropriate variables. My approach looks like this: template <typename T> inline void pack (std::vector< uint8_t >& dst, T& data) { uint8_t * src = static_cast < uint8_t* >(static_cast < void * >(