serialization

How to exclude a property from being serialized in System.Text.Json.JsonSerializer.Serialize() using a JsonConverter

十年热恋 提交于 2020-06-27 09:35:08
问题 I want to be able to exclude a property when serializing using System.Text.Json.JsonSerializer. I don't want to use a JsonIgnore attribute everywhere I want to do this. I would like to be able to define the properties I want to exclude during serialization only, via some kind of Fluent API, which currently does not exist. The only option I was able to find is to define a JsonConverter and add it to the list of Converters on the JsonSerializerOptions that I pass to the Serialize() method like

Serialization issues DF vs. RDD

半城伤御伤魂 提交于 2020-06-27 04:11:12
问题 Hardest thing in Spark is Serialization imho. This https://medium.com/onzo-tech/serialization-challenges-with-spark-and-scala-a2287cd51c54 I looked at some time ago and I think I am pretty sure I get it, the Object aspects. I run the code and it is as per the examples. However, I am curious on a few other aspects when testing in a Notebook on a Databricks Community Edition account - not a real cluster BTW. I did check, confirm also on a Spark Standalone cluster via the spark-shell. This does

Not able to archive all the data

筅森魡賤 提交于 2020-06-23 12:37:05
问题 I am using boost for serialization of data. This is how the classes are structured. 1) I have a Stage class This class holds vector data for the director class class Stage { public: std::vector<Director> directors; void AddDirector(Director dir) { directors.push_back(dir); } int GetDirectorSize() { return directors.size(); } Director* GetDirector(int number) { return &directors[number]; } private: friend class boost::serialization::access; template<typename Archive> void save(Archive& ar,

Is this a bug in JSON.NET or Entity Framework or am I doing something wrong while trying to serialize a list of Exceptions with JSON.NET?

大城市里の小女人 提交于 2020-06-23 08:31:47
问题 Got this error when trying to serialize a set of errors: "ISerializable type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' does not have a valid constructor. To correctly implement ISerializable a constructor that takes SerializationInfo and StreamingContext parameters should be present." The constructor is in fact present in the base classes, but it is a protected member. Someone asked to see the JSON: { "$type": "System.Data.Entity.Infrastructure

How to read from file to Set with objectInputStream

我与影子孤独终老i 提交于 2020-06-22 04:31:41
问题 I'm trying to read some information from a file with ObjectInputStream method. For some reason, the file does not contain the information after the command executed. No error appears. This is my code : public boolean findUser(String user_id) throws Exception { try (ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(fILENAME))){ //System.out.println("Adsfasdf"); System.out.println(objectInputStream); Set<MarkoliaUser> users = (Set<MarkoliaUser>) objectInputStream

Not able to archive all the data

荒凉一梦 提交于 2020-06-17 09:58:13
问题 I am using boost for serialization of data. This is how the classes are structured. 1) I have a Stage class This class holds vector data for the director class class Stage { public: std::vector<Director> directors; void AddDirector(Director dir) { directors.push_back(dir); } int GetDirectorSize() { return directors.size(); } Director* GetDirector(int number) { return &directors[number]; } private: friend class boost::serialization::access; template<typename Archive> void save(Archive& ar,

how to change serialized JSON structure django rest framwork

為{幸葍}努か 提交于 2020-06-17 09:31:11
问题 I'm wondering if it possible to change structure of my JSON that im sedinding out. currenyly it looks like this: { "para_subject": { "discipline": "MATAN" }, "para_room": { "room": "210" }, "para_professor": { "user": { "username": "yyyy", "email": "yyyy.yyyy@gmail.com", "first_name": "yyyy", "last_name": "yyy" }, "middle_name": "xxxxxx" }, } what is the best way to change it to this: { "discipline": "MATAN", "room": "210", "para_professor": { "username": "yyyy", "email": "yyyy.yyyy@gmail.com

how to change serialized JSON structure django rest framwork

这一生的挚爱 提交于 2020-06-17 09:30:25
问题 I'm wondering if it possible to change structure of my JSON that im sedinding out. currenyly it looks like this: { "para_subject": { "discipline": "MATAN" }, "para_room": { "room": "210" }, "para_professor": { "user": { "username": "yyyy", "email": "yyyy.yyyy@gmail.com", "first_name": "yyyy", "last_name": "yyy" }, "middle_name": "xxxxxx" }, } what is the best way to change it to this: { "discipline": "MATAN", "room": "210", "para_professor": { "username": "yyyy", "email": "yyyy.yyyy@gmail.com

Serialise an object to URL parameter string - Including properties from nested objects

泪湿孤枕 提交于 2020-06-17 09:13:25
问题 I have a class which contains a property who's type is another class. For example: public class Outer { public string SomeStringProperty { get; set; } public Inner SomeClassProperty { get; set; } } public class Inner { public string InnerProperty1 { get; set; } public string InnerProperty2 { get; set; } } I want to convert an instance of the Outer class to a URL query string, and include the properties from the nested Inner class. For example, given an instance of Outer , such as: Outer

Why do data classes not implement Serializable?

﹥>﹥吖頭↗ 提交于 2020-06-16 02:48:26
问题 I am new to kotlin but a veteran of scala . The former has impressed me so far. But at this moment I am working through a head scratcher - that the data class does not implement Serializable . How a class with that name could expected to not be routinely expected to be used in that manner eludes me. What are the technical challenge(s) that precluded that support? I'm interested because i'd like to create a wrapper. It seems that the expectation is to always provide a serializer() ? That is