deserialization

Json.NET - Default deserialization behavior for a single property in CustomCreationConverter

依然范特西╮ 提交于 2019-12-12 08:30:55
问题 In the following scenario, how do I get CrazyItemConverter to carry on as usual when it encounters a JSON property that exists in the type I'm deserializing to? I have some JSON that looks like this: { "Item":{ "Name":"Apple", "Id":null, "Size":5, "Quality":2 } } The JSON gets deserialized into a class that looks a whole lot like this: [JsonConverter(typeof(CrazyItemConverter))] public class Item { [JsonConverter(typeof(CrazyStringConverter))] public string Name { get; set; } public Guid? Id

XML De-serialize into type based on attribute

风流意气都作罢 提交于 2019-12-12 05:08:57
问题 I have the following Piece of XML: <values> <value type="A"> <something>ABC</something> <something-else>DEF</something-else> </value> <value type="B"> <something-different>ABC</something-different> <something-complex> <id>B</id> <name>B</name> </something-complex> </value> How would I create the C# code to de-serialize this properly? Normally I'd do something like: public class A { [XmlElement("something")] public string Something { get; set; } [XmlElement("something-else")] public string

NotSerializableException even after implementing Serializable

风流意气都作罢 提交于 2019-12-12 04:49:28
问题 Recieving the error: java.io.NotSerializableException even after implementing Serializable. I'm simply trying to serialize a Survey object. Here is my code, does anyone have an idea why I am receiving this error? public void loadData(Survey survey, Test test, Boolean isSurvey) throws FileNotFoundException { ... try { ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fileName)); Survey s = (Survey) ois.readObject(); ois.close(); System.out.println("list size = " + s.questions);

Deserialization of array with DataContractJsonSerializer with Windows Store App

佐手、 提交于 2019-12-12 04:38:09
问题 Is it possible to deserialize a json array with native DataContractJsonSerializer in a Windows Store App? Example, from: [{"groups":[{"name":"tom","vip":false},{"name":"sam","vip":true}]},{"groups":[{"name":"pam","vip":false},{"name":"mom","vip":true}]}] To, anything roughly in the line of: public class Group { public string name { get; set; } public bool vip { get; set; } } [DataContract] public class RootObject { [DataMember] public List<Group> groups { get; set; } } So far, my attempts

How to deserialize a file back to the original class object [closed]

不打扰是莪最后的温柔 提交于 2019-12-12 04:36:41
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 9 months ago . I created a class and I periodically save objects of this class to internal storage using Serializable. When I want to retrieve these objects, I use this approach: for(File i: getFilesDir().listFiles()){ //Skipped enclosing try-catch block FileInputStream fis = openFileInput(i

XmlSerializer in C#, deserialize a class decorated with multiple XmlElement with same name by a particular attribute?

大兔子大兔子 提交于 2019-12-12 04:22:27
问题 I have a class which is decorated with XmlElement in a wrong way, but it has also attributes that could allow me to identify the fields I need. I can only modify [IWantToSerializeThisAttribute] and add other attributes to MySerializableClass because any modification to property names or XmlElement names would involve heavy coding maintenance. Here's how the class has been defined: [XmlRoot("ARandomXmlRoot")] public class MySerializableClass { //CAMPI DIR_DOCUMENTI //[MetadatoDocumentoAlfresco

Gson deserialize json of embedded member

限于喜欢 提交于 2019-12-12 04:15:15
问题 I have the following sample JSON: { "birds":[ { "id":"SAMPLEID", "isTest":true, "externalId":{ "Main":[ "123ABC" ], "Sub":[ "456" ] }, "dinos":[ ], "rhinos":[ { "id":"SUPER100ID", "isTest":true, "externalId":{ "famousId":[ "23|45" ] }, "dinos":[ ], "pelicans":[ { "id":"D4CLIK", "isTest":true, "bird":null, "crazyArray":[ ] }, { "id":"DID123", "type":"B", "name":"TONIE", "isTest":true, "bird":null, "subspecies":[ ] } ] } ] } ], "metaData":{ "count":1 } } I want to use GSON to deserialize this

Jackson: Deserialize JSON-Array in different attributes of an object

孤街醉人 提交于 2019-12-12 03:36:20
问题 I need to decode the following JSON-Structure: { "id":1 "categories": [ value_of_category1, value_of_category2, value_of_category3 ] } The object I am trying to deserialize into is of the following class: class MyClass { public Integer id; public Category1 category1; public Category2 category2; public Category3 category3; ... } public enum Category1{ ... } public enum Category2{ ... } public enum Category3{ ... } In the JSON the first entry of the categories-Array is always a value of the

Serial Data communication Arduino

这一生的挚爱 提交于 2019-12-12 03:28:10
问题 I currently am trying to read the serial output from a small capacitance meter(model DN060-02v04 from JYETECH). I have the arduino UNO set up to read the meter output. I do get data, but it is not readable and does not correspond to the format outlined in the manual. My baud rates match at 38400bps. The meter claims a 8-N-1 configuration. I'm using the SerialSoftware example in the Arduino Library to read it. #include <SoftwareSerial.h> SoftwareSerial mySerial(2, 3); // RX, TX void setup() {

Deserializing Multidimensional array from JSON with ServiceStack fails

ぐ巨炮叔叔 提交于 2019-12-12 03:22:10
问题 I have an object with a single double[,] property, which was serialized using ServiceStack ToJson() method as follows: {"xy":[[-2.9774,-2.0682],[-1.1378,2.7118]]} However I cannot deserialize it back to my object type ( Parameters ) using "abovestring".FromJson<Parameters>() as it throws the following exception: System.Runtime.Serialization.SerializationException: Failed to set property 'xy' with '[[-2.9774,-2.0682],[-1.1378,2.7118]]' ---> System.FormatException: Input string was not in a