serialization

Serialize inherited classes using protobuf-net

血红的双手。 提交于 2020-01-15 05:58:29
问题 I have a problem serializing derived classes using protobuf-net. I don't know if it is because it is not supported, or I am doing something wrong. I have a generic base class (which I can serialize directly) and then i make a specialization of this, but this one I can't serialize. The following is the code for the two classes and a example of usage. Am i doing something wrong? Edit Added restriction to the generic types Base [ProtoBuf.ProtoContract] public class Base<TKey, TValue> where TKey

How do I pass custom ArrayAdapter Object between Intents with serialization

孤人 提交于 2020-01-15 05:01:49
问题 Background : I am just starting with Android and I have learned about Intents and ListView . I have am creating a simple app where a user enter some information and that information is added into ListView. For this I have created a ListView in my MainActivity class. Created a class for Objects named User and created Custom ArrayAdapter UserAdapter. Both of my classed User and UserAdapter implements Serializable marker interface. Now whenever someone click on button from MainActivity class to

How do I pass custom ArrayAdapter Object between Intents with serialization

自古美人都是妖i 提交于 2020-01-15 05:01:32
问题 Background : I am just starting with Android and I have learned about Intents and ListView . I have am creating a simple app where a user enter some information and that information is added into ListView. For this I have created a ListView in my MainActivity class. Created a class for Objects named User and created Custom ArrayAdapter UserAdapter. Both of my classed User and UserAdapter implements Serializable marker interface. Now whenever someone click on button from MainActivity class to

Java why a Map of Map (ex: Map<String,Map<String,String>>) not serializeable

淺唱寂寞╮ 提交于 2020-01-15 02:33:38
问题 We are using HashMap in JDK 1.7 and I face some issue during the code review with SonarQube . Please consider below samples: public class SerializationTest implements Serializable { private Map<String,String> test1=new HashMap<>(); //Serializeable private Map<ANEnum,String> test2=new HashMap<>(); //Serializeable private Map<String,ASerializeableObject> test3=new HashMap<>(); //Serializeable private Map<String,Map<String,String>> test4=new HashMap<>(); //Not Serializeable private Map<ANEnum

Java why a Map of Map (ex: Map<String,Map<String,String>>) not serializeable

筅森魡賤 提交于 2020-01-15 02:32:37
问题 We are using HashMap in JDK 1.7 and I face some issue during the code review with SonarQube . Please consider below samples: public class SerializationTest implements Serializable { private Map<String,String> test1=new HashMap<>(); //Serializeable private Map<ANEnum,String> test2=new HashMap<>(); //Serializeable private Map<String,ASerializeableObject> test3=new HashMap<>(); //Serializeable private Map<String,Map<String,String>> test4=new HashMap<>(); //Not Serializeable private Map<ANEnum

Java why a Map of Map (ex: Map<String,Map<String,String>>) not serializeable

拈花ヽ惹草 提交于 2020-01-15 02:31:05
问题 We are using HashMap in JDK 1.7 and I face some issue during the code review with SonarQube . Please consider below samples: public class SerializationTest implements Serializable { private Map<String,String> test1=new HashMap<>(); //Serializeable private Map<ANEnum,String> test2=new HashMap<>(); //Serializeable private Map<String,ASerializeableObject> test3=new HashMap<>(); //Serializeable private Map<String,Map<String,String>> test4=new HashMap<>(); //Not Serializeable private Map<ANEnum

Jackson serialization ignore negative values

无人久伴 提交于 2020-01-14 19:23:48
问题 I have an Object like this: public class MyObject { private String name; private int number; // ... } And I want to include the number only if the value is not negative ( number >= 0 ). While researching I found Jackson serialization: ignore empty values (or null) and Jackson serialization: Ignore uninitialised int. Both are using the @JsonInclude annotation with either Include.NON_NULL , Include.NON_EMPTY or Include.NON_DEFAULT , but none of them fits my problem. Can I somehow use

Serializing XML with strange namespaces?

随声附和 提交于 2020-01-14 13:58:13
问题 Question: How does the class for the serialization of this XML content look ? <?xml version="1.0" encoding="utf-8"?> <vcc:CreateTextSearchResponse xmlns:vcc="urn:veloconnect:catalog-1.1" xmlns:vct="urn:veloconnect:transaction-1.0"> <vct:BuyersID>12345</vct:BuyersID> <vct:ResponseCode>200</vct:ResponseCode> <vct:TransactionID>225</vct:TransactionID> <vct:StatusCode>2</vct:StatusCode> <vct:IsTest>false</vct:IsTest> <vcc:TotalCount>3876</vcc:TotalCount> </vcc:CreateTextSearchResponse> If I let

ActiveRecord serialize sending nil to custom serializer for present attribute

柔情痞子 提交于 2020-01-14 13:43:23
问题 I have the following custom serializer: class ReportCardDataSerializer def self.dump(hash) hash.to_json end def self.load(json) # json.class == NilClass, why???? hash = (json || {}).with_indifferent_access end end And the following class with a serialized data attribute with database column set to NOT NULL. class ReportCardGroup < ActiveRecord::Base serialize :data, ReportCardDataSerializer # data is PostgreSQL jsonb column end The ReportCardDataSerializer dump method works as expected. But

@JsonFormat DEFAULT_TIMEZONE doesn't seem to be working

安稳与你 提交于 2020-01-14 13:42:39
问题 I am having some issue with date logic which I've isolated to Jackson, the JSON serializer. In the database and in a debug point in the application, dates are correct and everything is written using default timezone. However, in serialization 4 hours are being added. I found this could be remedied by telling Jackson specifically to use EST (it was defaulting to UTC). As below: @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss.SSSZ", timezone="America/New_York") private