deserialization

How to serialize/deserialize an object loaded from another assembly?

时间秒杀一切 提交于 2020-01-09 09:07:13
问题 I want to serialize/deserialize an object that has been instantiated by another object loaded from an assembly: Interfaces.cs (from a referenced assembly, Interfaces.dll) public interface ISomeInterface { ISettings Settings { get; set; } } public interface ISettings : ISerializable { DateTime StartDate { get; } } SomeClass.cs (from a referenced assembly, SomeClass.dll) public class SomeClass : ISomeInterface { private MySettings settings = new Settings(); public ISettings Settings { get {

Trouble serializing and deserializing multiple objects

不问归期 提交于 2020-01-09 08:19:30
问题 I currently playing with the XMLSerializer to understand how it works. I am able to serialize, save and de-serialize a single object without problem. However I run into problems when I try to de-serialize multiple objects. I get this error : Unhandled exception. System.InvalidOperationException: There is an error in XML document (10, 10). ---> System.Xml.XmlException: Unexpected XML declaration. The XML declaration must be the first node in the document, and no whitespace characters are

Json.NET Disable the deserialization on DateTime

China☆狼群 提交于 2020-01-08 16:22:25
问题 Here is the code: string s = "2012-08-08T01:54:45.3042880+00:00"; JObject j1 = JObject.FromObject(new { time=s }); Object o = j1["time"]; We can check that o is string and equals "2012-08-08T01:54:45.3042880+00:00" Now we transfer j1.ToString() to another program, which is { "time": "2012-08-08T01:54:45.3042880+00:00" } then at the other program, try to parse it back to JObject, which is JObject j2 = JObject.Parse(j1.ToString()); Object o2 = j2["time"]; Now, if we check o2, o2's type is Date,

GSON does not deserialize reference to outer class

浪尽此生 提交于 2020-01-07 05:29:05
问题 On my Java application, I defined two classes, called A and B where B is inner class of A . Both are defined as serializable public class A implements Serializable { int attrParent; List<B> items = new ArrayList<B>(); public void setAttrParent(int attrParent) { this.attrParent = attrParent; } public int getAttrParent() { return attrParent; } public class B implements Serializable { private int attr; public void setAttr(int attr) { this.attr = attr; } public int getAttr() { return attr; }

deserialize system.outofmemoryexception on a networkstream

时光毁灭记忆、已成空白 提交于 2020-01-07 05:09:14
问题 I've got a serializeable class called Cereal with several public fields shown here <Serializable> Public Class Cereal Public id As Integer Public cardType As Type Public attacker As String Public defender As String Public placedOn As String Public attack As Boolean Public placed As Boolean Public played As Boolean Public text As String Public Sub New() End Sub End Class My client computer is sending a new Cereal to the host by serializing it shown here 'sends data to host stream (c1) Private

Newtonsoft JSon Deserialize into Primitive type

独自空忆成欢 提交于 2020-01-06 20:00:33
问题 In my C# program, I am querying a webservice and getting a reply stream back in JSON that looks something like this: {"val":12345.12},{"val":23456.23},{"val":34567.01},... or, with possibly more than 1 value per reply object: {"val1":12345.12,"val2":1},{"val1":23456.23,"val2":3},.... And I have the following code utilizing the Newtonsoft.Json library that parses the stream and performs some action on each parsed object, one at a time: public void ParseReply<T>(StreamReader sr, Action<T>

Newtonsoft JSon Deserialize into Primitive type

本小妞迷上赌 提交于 2020-01-06 19:59:17
问题 In my C# program, I am querying a webservice and getting a reply stream back in JSON that looks something like this: {"val":12345.12},{"val":23456.23},{"val":34567.01},... or, with possibly more than 1 value per reply object: {"val1":12345.12,"val2":1},{"val1":23456.23,"val2":3},.... And I have the following code utilizing the Newtonsoft.Json library that parses the stream and performs some action on each parsed object, one at a time: public void ParseReply<T>(StreamReader sr, Action<T>

How to deserialize the xmlelement containing List in xml

故事扮演 提交于 2020-01-06 14:19:55
问题 I am using silverlight5 and c# to achieve my targets. I have xml file below: string xmlstring = <?xml version="1.0" encoding="utf-8" ?> <parameter> <name>bands_amounts</name> <label>Bands Amounts</label> <unit></unit> <component> <type>List</type> <attributes> <type>Integer</type> <displayed>4</displayed> <add_remove>yes</add_remove> <item>1 000 000</item> <item>5 000 000</item> <item>10 000 000</item> <item>20 000 000</item> </attributes> <attributes> <ccypair>XAUUSD</ccypair> <item>100<

How to deserialize the xmlelement containing List in xml

十年热恋 提交于 2020-01-06 14:18:02
问题 I am using silverlight5 and c# to achieve my targets. I have xml file below: string xmlstring = <?xml version="1.0" encoding="utf-8" ?> <parameter> <name>bands_amounts</name> <label>Bands Amounts</label> <unit></unit> <component> <type>List</type> <attributes> <type>Integer</type> <displayed>4</displayed> <add_remove>yes</add_remove> <item>1 000 000</item> <item>5 000 000</item> <item>10 000 000</item> <item>20 000 000</item> </attributes> <attributes> <ccypair>XAUUSD</ccypair> <item>100<

C# / Json.net / how can i deserialize the message?

别等时光非礼了梦想. 提交于 2020-01-06 14:16:34
问题 please help me on what i need to do next? i need this message to be inside their dedicated strings but i got no idea how to do it also how about using a dictionary? the message that i receive is this.. its inside a string called sServerResponse {"pcname": "Kat", "pause": [], "ip": "192.168.1.100", "paused": 0, "services": [], "session": "", "shop": [], "end": 0, "used": 0, "start": 0, "timeup": 0, "follow": "sui", "consq": {"1": "basic", "3": "rounding", "2": "minimum"}, "stas": 0, "price": 0