deserialization

WCF deserializing - choosing type in depends on some field - once and for all deciding this issue

独自空忆成欢 提交于 2019-12-13 00:38:32
问题 Is it possible to help deserializer of WCF ? I mean that in my soap messages I send some special field like: <someField>someValue</someField> And based on this someField I give a hint to WCF deserializer what type it should deserialize ? 来源: https://stackoverflow.com/questions/43506726/wcf-deserializing-choosing-type-in-depends-on-some-field-once-and-for-all-de

PortoBuf-net Deserializes a double-sized version of the serialized double array

限于喜欢 提交于 2019-12-13 00:27:19
问题 [Serializable] [ProtoContract] public class DataWrapper { [ProtoMember(1)] public double[] Data = new double[] { 1, 2, 3, 4 }; } class Program { static void Main(string[] args) { Dictionary<int, DataWrapper> serialized = new Dictionary<int, DataWrapper>(); Dictionary<int, DataWrapper> deserialized;// = new Dictionary<int, OHLC>(); for (int i = 0; i < 10; i++) { serialized.Add(i, new DataWrapper()); } using (FileStream ms = new FileStream("dictionary", FileMode.Create, FileAccess.Write)) {

deserialize existing xml into custom object

落爺英雄遲暮 提交于 2019-12-12 22:34:30
问题 I have the following xml: <state> <groups> <group id='1' name='Basic Search Options'> <control name='Building' label='In' display='true' configurable='false'/> <control name='SearchType' label='For' display='true' configurable='false'/> <control id='1' default='C' name='Search By' label='By'> <option searchtype='C' searchmode='Cnumber' value='CNumber' label='C Number' display='true'/> <option searchtype='C' searchmode='crossrefnumber' value='CNumber1' label='Cross Reference Number' display=

XML mapping to objects without attributes in C#

不羁岁月 提交于 2019-12-12 18:01:38
问题 Is there a C# library that allows mapping C# objects to XML without Attributes? I have several data sources, all of them containing XML data with the same logical-structure, but different schema. For example in one XML there might be a field called 'zip-code', in another this data will be in attribute called 'postal-code' etc. I want to deserialize all XML sources in single C# class. Obviously I can not use XMLAttrubtes, because there are different 'paths'. I want something like EclipseLink

Different JSON array response

落花浮王杯 提交于 2019-12-12 17:22:08
问题 I have problems parsing two different JSON responses. 1: This is the JSON response I get from a RESTful API: { "gear": [ { "idGear": "1", "name": "Nosilec za kolesa", "year": "2005", "price": "777.0" }, { "idGear": "2", "name": "Stresni nosilci", "year": "1983", "price": "40.0" } ] } 2: This response I get from my testing client. I was added some values to the list and then I used gson.toJson for testing output. [ { "idGear": "1", "name": "lala", "year": 2000, "price": 15.0 }, { "idGear": "2"

Deserialize JSON into custom list

心已入冬 提交于 2019-12-12 17:19:15
问题 I have this json: var x = [ [99,"abc","2dp",{"GroupNum": 0,"Total":[4, 1]}], [7,"x","date"], [60,"x","1dp",{"GroupNum": 1}], ... ] The following rules exist (let i refer to the inner list index): x[i][0] - mandatory item - always an integer x[i][1] - mandatory item - always a string x[i][2] - mandatory item - always a string x[i][3] - optional item - when it exists then it has the following rules: x[i][3].GroupNum - mandatory field - always an integer x[i][3].Total - optional field - when it

Force JObject to serialzie date in “dd-mm-yyyy” format

牧云@^-^@ 提交于 2019-12-12 16:19:01
问题 public Guid AddJobs(JObject parametrs) { dynamic jsonParameters = parametrs; JobViewModel job = jsonParameters.Job.ToObject<JobViewModel>(); } Above is my code. I am trying to deserialize this model using above method. The problem is that it keeps on giving me exception that date is not in correct format as it is not expecting "dd-mm-yyyy". Please Help me out in this. 回答1: Here's two approaches: 1.Set the format directly on the serializer. It will throw an exception on incorrect values. var

Newtonsoft.Json Cannot create and populate list type

我只是一个虾纸丫 提交于 2019-12-12 15:49:13
问题 I have a model: [Serializable] public class User { public string UserID { get; set; } public string UserName { get; set; } public string Password { get; set;} public bool isLoggedIn { get; set; } public CookieCollection Cookies { get; set; } [NonSerialized] public string Response = ""; } Just trying to serialize and deserialize: string str = Newtonsoft.Json.JsonConvert.SerializeObject(u, typeof(User), settings); User us = Newtonsoft.Json.JsonConvert.DeserializeObject<User>(str); I am getting

C# Newtonsoft deserialize JSON array

岁酱吖の 提交于 2019-12-12 14:53:28
问题 I'm trying to deserialize an array using Newtonsoft so i can display files from a cloud based server in a listbox but i always end up getting this error no matter what i try: Newtonsoft.Json.JsonReaderException: 'Unexpected character encountered while parsing value: [. Path '[0].priv', line 4, position 15.' Thisis an example try to deserialize: [ { "code": 200, "priv": [ { "file": "file.txt", "ext": "txt", "size": "104.86" }, { "file": "file2.exe", "ext": "exe", "size": "173.74" }, ], "pub":

How do you serialize a guava collection?

故事扮演 提交于 2019-12-12 14:39:57
问题 I must be missing something obvious but I can't manage to serialize a TreeBasedTable . It is marked as @GwtCompatible(serializable = true) , so my understanding is that I need to use the guava-gwt library to (de-)serialize it. But I can't find do that. A contrived code example would be extremely appreciated. For information, my pom contains guava and guava-gwt , both version 14.0. EDIT So thanks to the answer, I now understand that TreeBasedTable is serializable. So I have removed all the gwt