serialization

Type 'System.Web.HttpInputStream' cannot be serialized

柔情痞子 提交于 2019-12-24 06:51:50
问题 I have been trying to design a WCF file upload service and am getting the following error in my web application: Type 'System.Web.HttpInputStream' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. See the Microsoft .NET Framework documentation for other supported types. Based on this error, I have tried re-marking my FileTransfer class with DataContractAttribute and

NullPointerException deserializing with gson

好久不见. 提交于 2019-12-24 06:40:36
问题 I have a JSON that contains the following: {"p1":{"debris":{"titanium":0,"silicum":0}},"p2":{"debris":{"titanium":0,"silicum":0}}... I declare the data using HashMap: public class Galax { public HashMap <String, InnerObject> pos; } public class InnerObject { public Debris debris; } public class Debris { public double titanium, silicum; } And I call the data using this: Galax galax = new Gson().fromJson(strGalaxy, Galax.class); System.out.println(galax.pos.get("p2").debris.titanium); The

System.Text.Json API is there something like IContractResolver

佐手、 提交于 2019-12-24 06:30:51
问题 In the new System.Text.Json; namespace is there something like IContractResolver i am trying to migrate my project away from Newtonsoft. This is one of the classes i am trying to move: public class SelectiveSerializer : DefaultContractResolver { private readonly string[] fields; public SelectiveSerializer(string fields) { var fieldColl = fields.Split(','); this.fields = fieldColl .Select(f => f.ToLower().Trim()) .ToArray(); } protected override JsonProperty CreateProperty(MemberInfo member,

c++/boost fusion handle parent class

試著忘記壹切 提交于 2019-12-24 06:28:10
问题 Lets suppose I have such classes hierarchy: enum class Type { DUMMY }; struct Base { int a; explicit Base(int a) : a(a) {} virtual ~Base() {} virtual Type type() = 0; }; struct Foo1 : public Base { double b; Foo1(int a, double b) : Base{a}, b(b) {} Type type() override { return Type::DUMMY; } }; all derived from Base using single inheritance and not defined any virtual methods, except overriding type() method. And I want to have meta info for each derived from Base to serialization and debug

XML Serialization of a List<DateTime> using a custom datetime format

泪湿孤枕 提交于 2019-12-24 05:57:33
问题 I have some troubles with an XML Serialization. (Probably something similar to THIS SO QUESTION, but regarding serialization instead of deserialization). I need to serialize a List<DateTime> , using a custom DateTime format. I'm able to do it for a single DateTime variable, but I can't figure out how to do it for a list. Here is what I'm trying to do in my code. For the simple DateTime variable I use this code: [XmlType("Time")] public class Time : BaseClass { public Time() { base.Name =

XML Serialization of a List<DateTime> using a custom datetime format

僤鯓⒐⒋嵵緔 提交于 2019-12-24 05:57:11
问题 I have some troubles with an XML Serialization. (Probably something similar to THIS SO QUESTION, but regarding serialization instead of deserialization). I need to serialize a List<DateTime> , using a custom DateTime format. I'm able to do it for a single DateTime variable, but I can't figure out how to do it for a list. Here is what I'm trying to do in my code. For the simple DateTime variable I use this code: [XmlType("Time")] public class Time : BaseClass { public Time() { base.Name =

Flatten JSON based on an attribute - python

ε祈祈猫儿з 提交于 2019-12-24 05:46:35
问题 I have a json array like this: [ { 'id': 1, 'values': [ { 'cat_key': 'ck1' }, { 'cat_key': 'ck2' } ] }, { 'id': 2, 'values': [ { 'cat_key': ck3 } ] } ] I want to flatten this array on the field values such that: [ { 'id': 1, 'cat_key': 'ck1' }, { 'id': 1, 'cat_key': 'ck2' }, { 'id': 2, 'cat_key': 'ck3' } ] What is the most efficient way to do this in python? 回答1: obj = json.loads(json_array) new_obj = [] for d in obj: if d.get('values'): for value in d['values']: new_obj.append(dict(id=d['id'

Serializing and deserializing TimeSpan values to a property of type Object

南楼画角 提交于 2019-12-24 05:42:17
问题 I have a class that has a field of type Object that may contain a TimeSpan object. I am serializing this and the deserializing this: public class MyObject { public object myTimeSpan { get; set; } } ... var myObject = new MyObject { myTimeSpan = TimeSpan.FromDays(2) }; var json = JsonConvert.SerializeObject(myObject); ... var duplicateObject = JsonConvert.DeserializeObject<MyObject>(json); And when I do, duplicateObject.myTimeSpan contains the string "2:00:00". How can I get this to

Microsoft.WindowsAzure.Storage.Table.TableEntity is not marked as serializable using Storage 4.3.0.0

最后都变了- 提交于 2019-12-24 05:22:28
问题 I am trying to move to Azure's Redis Cache, but I am getting Type 'Microsoft.WindowsAzure.Storage.Table.TableEntity' in Assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable. when trying to serialize TableEntity or a class that inherits TableEntity. This SO Post indicates the issue was fixed after 4.0.0 - any ideas? 回答1: As per Breaking Changes description, this is intentionally removed and didn't come back:

Microsoft.WindowsAzure.Storage.Table.TableEntity is not marked as serializable using Storage 4.3.0.0

微笑、不失礼 提交于 2019-12-24 05:22:09
问题 I am trying to move to Azure's Redis Cache, but I am getting Type 'Microsoft.WindowsAzure.Storage.Table.TableEntity' in Assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable. when trying to serialize TableEntity or a class that inherits TableEntity. This SO Post indicates the issue was fixed after 4.0.0 - any ideas? 回答1: As per Breaking Changes description, this is intentionally removed and didn't come back: