deserialization

Exception occurs when trying to deserialize using Json.Net [duplicate]

拟墨画扇 提交于 2019-12-13 09:38:06
问题 This question already has answers here : Deserializing JSON into one of several C# subclasses (1 answer) Deserializing polymorphic json classes without type information using json.net (5 answers) Closed 5 months ago . I am trying to deserialize the following json using Json.Net into C# classes as defined below. I am having this exception: Newtonsoft.Json.JsonSerializationException: 'Could not create an instance of type Viewer.ShapeDto. Type is an interface or abstract class and cannot be

java.io.EOFException when serialize object from child process and try to de-serialize from parent process ProcessBuilder

删除回忆录丶 提交于 2019-12-13 08:39:58
问题 I am creating a new process using java ProcessBuider and I want an object to be sent to the parent from the creating child. Here, I serialize the object from child side and send it to the parent. But when I read the sent object from parent, there is an exception saying java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source) Felt like still there are no streams receive to the parent when I am trying to read that. Parent, Child and the Sending object java

Json.Net Deserialize Returning Nulls

谁都会走 提交于 2019-12-13 07:26:06
问题 I'm using the Petfinder API and trying to return a root object in my C# code. I used the Json class generator to generate the classes, but the Deserialize function is returning nulls. This is my C# code: using (var client = new WebClient()) { var json = new WebClient().DownloadString("http://api.petfinder.com/shelter.getPets?format=json&key=<key>&id=<id>"); Petfinder deserializedPet = JsonConvert.DeserializeObject<Petfinder>(json); } The Petfinder object is defined as: internal class

Weird error when i try to Deserialize a xml string to a .net List Object

前提是你 提交于 2019-12-13 06:26:04
问题 I have asked this question twice already but not one have given me an answer that actually works so i will try again. I have this xml: <?xml version="1.0" encoding="UTF-8"?> <people type="array"> <person> <first-name>Mark</first-name> <last-name>Zette</last-name> <e-mail>mark.zette@hotmail.com</e-mail> </person> <person> <first-name>Sara</first-name> <last-name>Brobro</last-name> <e-mail>brobro@hotmail.com</e-mail> </person> <person> <first-name>Rob</first-name> <last-name>Sel</last-name> <e

Help with implementing IXmlSerializable on this XML

断了今生、忘了曾经 提交于 2019-12-13 05:40:01
问题 Here's the XML: <?xml version="1.0" encoding="utf-8" ?> <SAPPHIRE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <TRANSACTION-CODE>NEW</TRANSACTION-CODE> <CUSTOMER-NUMBER>100398598</CUSTOMER-NUMBER> <CUSTOMER-NAME>CART DUDE</CUSTOMER-NAME> <ACCOUNT-TYPE /> <PERSON FNAME="CART" LNAME="DUDE" RESPONSIBLITY="CART DUDE" /> <SOURCE>cplestore</SOURCE> <TRAN-REFERENCE>13374470</TRAN-REFERENCE> <ORDER> <ORDER-NUMBER NUMBER="00241662693" REFERENCE=

C# XML deserialization XmlAttribute

吃可爱长大的小学妹 提交于 2019-12-13 05:04:05
问题 2Let's say I have this array: <something> <items1 note="some text"> <item1></item1> <item1></item1> <item1></item1> </items1> <items2> <item2></item2> <item2></item2> <item2></item2> </items2> </something> And I have a model: public class Something { public string Item1Note { get; set; } public List<Item1> Items1 { get; set; } public List<Item2> Items2 { get; set; } } So, Is it possible to deserialize XML into the model so that the attribute note of Items1 node was in property Item1Note. Thx

protobuf-net deserialization System.IO.EndOfStreamException under mono

依然范特西╮ 提交于 2019-12-13 04:38:10
问题 I have been using protobuf-net to send some objects over the wire and everything has been working nicely until now. However, I have come across a particular instantiation of my class that fails to deserialize when running under mono. The exact same object deserializes correctly running under .net. I have verified that it is the exact same byte[] that I receive over the wire when I run under mono and under .net by checking the md5 sum. This would indicate that the problem must be with protobuf

Deserialized Xml Object Loop Throws NullReferenceException

别等时光非礼了梦想. 提交于 2019-12-13 04:26:29
问题 This is sort of a continuation of another question and all of the code related to this question can be found, Here. I am experiencing a strange NullReferenceException Error that I just can't figure out. I am trying to build a table from a Deserialized web response. When I go to iterate through the object items I hit a NRE. The weird thing is I tested my condition statement by its self and I am able to catch it. Here is my code: public string getExample() { DataTable dt = new DataTable();

Get only value from JSONArray, i.e. without also the key, in Java

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 03:57:19
问题 I'm looking for a way to return only the value after a call to get() on a particular index of a JSONArray. Here'd the method I'm working with: private void parseMessageRedrawBoard(String message) throws Exception { Log.d("0000: ", message); String trimmed = message.substring(message.indexOf("[")); Log.d("1111: ", trimmed); JSONArray jsonArray = new JSONArray(trimmed); //"column 0" JSONObject subObject = jsonArray.getJSONObject(4); JSONArray result = subObject.getJSONArray("row 4"); Log.d("YES

Cannot access class methods via generics

不打扰是莪最后的温柔 提交于 2019-12-13 03:47:26
问题 I changed my method to generic method. What is happening now is that I was deserializing the class inside the methodB and accessing its methods which I can not do anymore. <T> void methodB(Class<T> clazz) { T var; HashMap<String, T> hash = new HashMap<>(); } void methodA () { methodB(classA.class); } Initially inside methodB with no generics, var = mapper.convertValue(iter.next(), ClassA.class); var.blah() //works fine After using generics, var = mapper.convertValue(iter.next(), clazz); var