serialization

Serializing Eigen::Matrix using Cereal library

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-01 04:26:45
问题 UPDATED : I managed to get it to work after I googled around and read the doxygen comments in code. Problem was that I missed the cast before using resize() method and also not using std::ios::binary for the streams. If you want to do something similar, better check the answer by Azoth. I am trying to serialize Eigen::Matrix type using Cereal. This is what I have (loosely based on https://gist.github.com/mtao/5798888 and the the types in cereal/types ): #include <cereal/cereal.hpp> #include

Custom Handler on JMSSerializerBundle is ignored

醉酒当歌 提交于 2020-02-01 02:54:11
问题 I am attempting to use a custom handler for JMS Serializer Bundle class CustomHandler implements SubscribingHandlerInterface { public static function getSubscribingMethods() { return array( array( 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, 'format' => 'json', 'type' => 'integer', 'method' => 'serializeIntToJson', ), ); } public function serializeIntToJson(JsonSerializationVisitor $visitor, $int, array $type, Context $context) { die("GIVE ME SOMETHING"); } } This does nothing, and

Understanding serialization of polymorphic objects in C++

北城以北 提交于 2020-01-30 13:19:02
问题 EDIT: I realised that the code below is a good example of what you cannot do in C++ with anything that is not a POD. There doesn't seem to exist a way to escape from having a typeid into the classes and do some sort of switch or table lookup (both of which must be carefully maintained) on the receiver side to rebuild the objects. I have wrote some toy code to serialise objects and two separate mains to write/read them to/from a file. common.h: #include <iostream> using namespace std; template

Understanding serialization of polymorphic objects in C++

女生的网名这么多〃 提交于 2020-01-30 13:18:52
问题 EDIT: I realised that the code below is a good example of what you cannot do in C++ with anything that is not a POD. There doesn't seem to exist a way to escape from having a typeid into the classes and do some sort of switch or table lookup (both of which must be carefully maintained) on the receiver side to rebuild the objects. I have wrote some toy code to serialise objects and two separate mains to write/read them to/from a file. common.h: #include <iostream> using namespace std; template

spring rest dynamically exclude Object properties from serialization

时光总嘲笑我的痴心妄想 提交于 2020-01-30 08:39:26
问题 i want to exclude specific properties of spring rest response body. after hours of googling around i found this: http://www.jroller.com/RickHigh/entry/filtering_json_feeds_from_spring due to its date i like to ask if there is something more up-to-date for jackson and or fasterxml. JsonView doesnt fit my requirements as i need to have such case covered: if A is the set of all my attributes: one time i need to expose B with B ⊂ A. another time C with C ⊂ A. And B ∩ C != ∅ this would cause

spring rest dynamically exclude Object properties from serialization

耗尽温柔 提交于 2020-01-30 08:39:10
问题 i want to exclude specific properties of spring rest response body. after hours of googling around i found this: http://www.jroller.com/RickHigh/entry/filtering_json_feeds_from_spring due to its date i like to ask if there is something more up-to-date for jackson and or fasterxml. JsonView doesnt fit my requirements as i need to have such case covered: if A is the set of all my attributes: one time i need to expose B with B ⊂ A. another time C with C ⊂ A. And B ∩ C != ∅ this would cause

struct serialization

丶灬走出姿态 提交于 2020-01-30 08:22:06
问题 There are some message structs. Each one can be serialized to a string and de-serialized from a string. For the serialization part, I use the overload operator <<. But for the de-serialization part, I cannot think of a proper way to do so. So I use a class to parse the string. Recently, I came across boost serialization. I don't know if it can serve this purpose or there is any better idea. struct S { int32_t type; double a; int32_t b; bool c; std::string d; friend std::ostream& operator<<

How to get Jackson to not output a field to XML when serializing

泪湿孤枕 提交于 2020-01-30 08:12:07
问题 Similar to this question I want to ignore a field in my java POJO . However, I want to always ignore the field whether or not it is null. In my case I need to populate the field value for logic but later when I am outputting my xml I do not want this field included. @AllArgsConstructor @NoArgsConstructor public class MyNotification { @Setter @Getter private String id; @Setter @Getter private String time; @Setter @Getter private String flag; @Setter @Getter private String event; @Setter

Serialize object using GSON

为君一笑 提交于 2020-01-30 06:23:10
问题 How can I serialize and deserialize this object with gson to json: public class test{ @Expose public List< Pair<Double,Double> > list; @Expose public int alpha; } I've tried this: Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); String str = gson.toJson(testInstance,test.class); where testInstance is an instance of class test, but it's not working because of Pair structure in List. 回答1: You have configured Gson object using excludeFieldsWithoutExposeAnnotation

DataContract not able to serialize collection members

两盒软妹~` 提交于 2020-01-30 05:26:13
问题 I have data that is best described as "onion-like" in that each outer layer builds on the one below it. Below you will see a vastly simplified version (mine is several layers deeper but exhibits the same behavior at each level). [CollectionDataContract] public abstract class AbstractTestGroup : ObservableCollection<AbstractTest> { [DataMember] public abstract string Name { get; set; } } [CollectionDataContract] [KnownType(typeof(Test))] public class TestGroup : AbstractTestGroup { public