Click here to Skip to main content
15,891,513 members
Everything / Deserialization

Deserialization

deserialization

Great Reads

by bk192077
I would like to define a C++ structure, pass the person instance to the mapping method along with JSON data, then use the filled structure. Or vice versa, get Person as JSON. StructMapping is trying to solve these problems.
by Dirk Bahle
Tips & Tricks on de/serializing Tree View based content with XML
by replaysMike
How to binary serialize your classes without having to modify them
by Robert P. Howard
How to deserialize a JSON string that contains nested polymorphic objects

Latest Articles

by bk192077
I would like to define a C++ structure, pass the person instance to the mapping method along with JSON data, then use the filled structure. Or vice versa, get Person as JSON. StructMapping is trying to solve these problems.
by Cinchoo
Use Cinchoo ETL to deserialize selective XML nodes from large XML file
by honey the codewitch
Designing infinitely scalable JSON: JSON (C++)
by Robert P. Howard
How to deserialize a JSON string that contains nested polymorphic objects

All Articles

Sort by Updated

Deserialization 

9 Jan 2017 by #realJSOP
3 Ways to Convert DataTable to JSON String in ASP.NET C#[^]
12 Apr 2019 by #realJSOP
I wrote extension methods to return a default value if the element didn't exist. Go to this CP article: Downloads: SQLXAgent - Jobs for SQL Express - Part 1 of 6[^] and scroll down to SqlxCommon\FileExtensions, and look for ExtendLinqToXML.cs BTW, I generally don't us the built-in .Net...
27 May 2015 by _Asif_
You can start by looking at below articleManipulate XML data with XPath and XmlDocument (C#)[^]
27 May 2015 by Acharya Raja Sekhar
Hi,I think you would like to deal with the deserialized object and want to find an object at specified path. Below code snippet might help you in doing this. class Program { static void Main(string[] args) { Student student = new Student { ID = 1,...
30 Jan 2015 by Afzaal Ahmad Zeeshan
The problem is that the required assembly is not found in your project. In the first line of the Exception, it is stated clearly, that the assembly (you can say, the .dll library or the package) required to deserialize, is not found. Did you include that package inside your project? Include (or...
13 Apr 2018 by Alaa Ben Fatma
In this article, we will walk through the basic concepts of de/serialization and how to create a very basic de/serializer.
2 Nov 2012 by Alan N
I've just tried this and I can't see a problem with the deserialisation. Do you cast the individual items of CircuitData's elements list to their actual run-time type? CircuitData cd = Read(); // deserialise foreach (ElementData ed in cd.elements) { if (ed is...
8 Aug 2013 by Antal Dominik
I'm trying to read a binary serialized object, that I don't have the object definition too. I took a peak into the file and saw property names, so I manually recreated the object (let's call it SomeDataFormat).I ended up with this : public class SomeDataFormat // 16 field { public...
12 Mar 2013 by Ariana Bond
Hi,I want to return a list containing DirectoryInfo , but i am getting an error of de-serialization.Please assist me how can i do this?Code Snippet--[OperationContract] private System.Collections.Generic.List GetSubDirectories(string directory) ...
4 Oct 2017 by Atlapure Ambrish
Try to add the following annotations to the top of your class, remember xml is case sensitive [Serializable, XmlRoot("Dump")] public partial class Dump { }
12 Jul 2013 by azeeth
Hi I have a need to deserialize an XML file which contains an image in base64 string. When I deserialize the XML the image is straight away populated as bytes by the following class. Which pretty much eliminates the need to do anything fancy and I write the image from those bytes. However a few...
5 Aug 2015 by Bal000
Hi,i am having trouble deserializing Xml. I get AccountInformation to work but it wont work with the Leauges. The Xml doesnt contain any tag for "Leauges" and i dont want to add that tag to get it to work. Is there any other way to "fix" it? [Serializable()] ...
3 Aug 2016 by Bernhard Hiller
When comparing your class definitions and the Json text, my impression is that you received a Skins object - but: the textures property is NOT a List(Of Textures), but a single object of type Textures.
3 Aug 2016 by Bernhard Hiller
This means that the encoding is different from the encoding you expected. You may experiment with other encodings (i.e. replace Encoding.UTF8), or ask the people who wrote the service supplying the json data which encoding they use.
1 May 2022 by bk192077
I would like to define a C++ structure, pass the person instance to the mapping method along with JSON data, then use the filled structure. Or vice versa, get Person as JSON. StructMapping is trying to solve these problems.
18 Oct 2013 by cherry chelsea
This is my XML structure after serializing Task ID 1 Task Desc 1 ...
23 Oct 2020 by Chris Copeland
You've not explained what the error is exactly but you're trying to deserialize to a LmodFileClass but that class doesn't have the "lmod_file" property that's expected. Instead you've created the inner Rootobject class containing this, have you...
7 Nov 2021 by Cinchoo
Use Cinchoo ETL to deserialize selective XML nodes from large XML file
22 Feb 2017 by Claudio Trenca
Hi, I'm fairly new to using JSON and I have a problem with deserialization of a json, I have a rest service that returns a JSON formatted like this: {result: [ { meta: [ [ "CODICE", "ftString", 16 ...
13 Nov 2017 by Claudio Trenca
#json # asp.net Hi everyone, I have a web service that gives me a json with this format: in case of positive login ["67", 1]; in the negative: ["fail", "Data entered for the user is incorrect."] how to properly deserialize? thank you all What I have tried: i try with : Dim ser As New...
12 Jan 2023 by Codes DeCodes
I am consuming SOAP services from my application and I get following XMl content as response consuming .wsdl file in my code. Toyota Fortuner Japan ...
13 Jul 2015 by ct_12
I can not deserialize the current JSON format. When I try to use some tools to generate the deserialize object it generates something like that ;public class RootObject{ public List> ImageList { get; set; }}JSON Format ;{"ImageList": [ [ { ...
17 Jul 2019 by Danny96
I am trying to save the updated values(save and reload) to a text file When user closes, re-opens, we should see the where it left off. 1)In this code, I have a button that changes the flag values to true, BUT, the main class does not see the changed flag values. Still, the old values are...
23 Jul 2019 by Danny96
Hello, I am (de)serializing the json strings to txt file. In my code object "c2" successfully does that where object "c1" fails to serialize and deserialize. Since object c1 fails, its boolean flags do not change. I searched for solutions, I saw some people merge the strings, and some use...
16 Feb 2016 by Dave-10169531
I have a JSON string that I am trying to convert. I can get the main part but there are two elements which are arrays part of the main that are not populating when I run the Deserializtion. Below is the data and the...
13 Nov 2013 by Davide Ardizzola
Hi there,i've a problem with a strange xml and I don't know how to deserialize it.This is the xml:
21 Nov 2013 by Davide Ardizzola
I've solved making the classes with this tool: Simple XML to Code.Bye!Davide.
28 Apr 2015 by dinesh_redhawk
I have to parse the data from a very big xml file with lot of repeatetive elements and child nodes. I could have used the GetElementsbyTagName but that will be a very lengthy and complex solution w.r.t this xml file.I think the best method would be xml serialization and deserialization...
11 May 2015 by dinesh_redhawk
Hello friends,Facing some problem with XML deserialisation. Please help:1) I have a XSD file, which i convert into a CS file using XSD tool. Tried to use this CS file in my project to deserialize a XML file (generated from the same XSD file). By doing this, iam getting error like "Cannot...
27 May 2015 by dinesh_redhawk
Hello friends,We have a big XML file (>27MB) to be parsed. We had deserialized the XML file into a XmlData object. The data from the XML is perfectly saved in this XmlData object in a proper structure of classes and objects.Now, the goal here is to get the specific node data from the...
29 May 2015 by dinesh_redhawk
Hello friends,I have to get the data of a specific node from a deserialised XML object.Below is the deserialization code snippet: //Using this object we can access the different classes & objects created from that XML XmlSerializer deserializer = new...
1 Jun 2015 by dinesh_redhawk
Hello friends,I have deserialized an XML and stored the data in an object (XmlData) public void CreateDeserializedXmlObject(string strSrcFilename) { try { //Using this object we can access the different classes & objects created...
22 Dec 2017 by Dirk Bahle
Tips & Tricks on loading and saving WPF Tree View based content.
18 Jan 2018 by Dirk Bahle
Tips & Tricks on de/serializing Tree View based content with XML
13 May 2016 by Dmitriy Gakh
I have no enough data about your solution and logic, but this code seems working without runtime errors (if it does not resolve your problem completely, it could be helpful to improve the situation and understand the code better):private void btnDelete_Click(object sender, EventArgs e) ...
8 Aug 2013 by E.F. Nijboer
Binary serialization is mostly suitable for use by an application internally and not really useful for data interchange. The obvious reason is that the format can be very specific between different framework versions. A better alternative would be to use xml or json formatters because these...
3 Jul 2015 by ebirazavi
I have written a program that enable users to generate some objects in WPF Canvas and run animations to them with set time. I used Xaml Serialization to save this objects stream and Deserialization to load events. I want to create video from steram and events. Is there any way to record events...
6 Jul 2012 by Eugenij Maudza
Is there any existing solution to read object graph from binari serialized state without loading assemblies.On client side it would be greate to work with middleware classes without loading appropriate dll.The idea is to read metadata of object that was taken from server side. Probably...
2 Aug 2016 by F-ES Sitecore
In the JSON "properties" is an array (the square brackets indicate an array), even if there is only one item in the array. So your properties field needs to be a list of PropertyX. Don't know vb.net I'm afraid but I believe it's something like "as List Of PropertyX" rather than just "as PropertyX"
16 Oct 2016 by F-ES Sitecore
dobj.results should be a list of two result objects so you can use that as a datasource for your objects, or show them in a view like@foreach(var result in Model.results){ // your html here @result.id}
7 Mar 2019 by F-ES Sitecore
Your xml isn't valid. Replace with The XML represents a single Vehicles node not a list of them so change the code accordingly XmlSerializer xmlSerializer = new XmlSerializer(typeof(Vehicles)); System.IO.StreamReader sr =...
12 Aug 2015 by Gaurav Aroraa
How to Serialize/Deserialize objects programatically?
23 Jan 2015 by George Swan
Your getDevotion method is expecting you to return a string but you are trying to return a Devotion.
12 Feb 2019 by Gerry Schmitz
The "case" doesn't match. The JSON element names are lower case; the class properties are upper case (the fields are lower case and not accessible).
7 Mar 2019 by Gerry Schmitz
Your "FourWheeler" and "Outbound" tags are "not matched". i.e. your XML is invalid.
7 Jan 2014 by gkishore84
I have a data contracts as follows: [DataContract] [KnownType(typeof(UserData))] [KnownType(typeof(CardData))] [XmlRoot(Namespace = Constants.XML_NMSP_TXN_MSG, ElementName = Constants.XML_TAG_COMMAND)] public class MessageData { [XmlAttribute("ID")] ...
7 Dec 2015 by Gopi krishna.ch
Here I have a scenario that Create xml file dynamically and it should be serialisable and my xml is like...
22 Feb 2017 by Graeme_Grant
Here is a Converter Helper class (converted from C#) used in commercial applications. It will convert to/From POCOs JSON.Imports Newtonsoft.JsonPublic Class JsonConverter Public Shared Function FromClass(Of T)(data As T, Optional isEmptyToNull As Boolean = False, Optional...
18 Sep 2017 by Graeme_Grant
First, you have a problem with an invalid ending tag - here: blue should be: blue same with: white should be: white Next, You need to generate classes for your XML. Here are two options: Option 1. (Preferred) Here is a useful tool...
13 Nov 2017 by Graeme_Grant
I ran your JSON sample through JSON Formatter & Validator[^] and it validates okay. Working with JSON in C# & VB[^] was written to answer questions like this one. Everything that you need to know is found in the article.
18 Jan 2018 by Graeme_Grant
This article goes into detail on how to Deserialize JSON and the tools that you can use to help you: Working with JSON in C# & VB[^] Here is the code generated by JSON Utils: Generate C#, VB.Net, SQL Table, Java and PHP from JSON[^]: namespace WhitePagesTool {         public class BelongsTo...
14 Jan 2018 by Graeme_Grant
The problem is that you're not mapping the JSON properties to the C# class properties correctly. This is why you are getting the error. Please look at Issues deserializing json in C# - Solution 1[^] to correctly map them.
9 Jan 2019 by Graeme_Grant
I wrote an article to help with all different types of questions related to JSON deserialization. You can find the answer to your question in this article: Working with JSON in C# & VB[^]
15 May 2019 by Graeme_Grant
As you're starting out with serialization of JSON data, this article answers this question and many others that you will have: Working with JSON in C# & VB[^]
21 Jul 2022 by Graeme_Grant
I have written an article that will answer this question and more: Working with JSON in C# & VB[^]
18 Oct 2022 by Graeme_Grant
JSON Utils: Generate C#, VB.Net, SQL TAble and Java from JSON[^] is my go to for generating C# classes from Json. There are many other tools and helpful information below that will answer many questions for you... * Working with Newtonsoft.Json...
26 Jan 2016 by infal
How to write / read multidimensional arrays to/from BinaryWriter/BinaryReader or other stream using UnmanagedMemoryStream
2 Aug 2016 by iProgramIt
Hello all,I am trying to deserialise some JSON in Visual Basic.However, I am having a bit of trouble. I am using Newtonsoft.Json.But I seem to keep getting this error when I try to deserialise some JSON:The JSON...
3 Aug 2016 by iProgramIt
Hello.I have yet another JSON deserialisation problem, and it's frustrating me. I have had a previous deserialisation problem (How do I deserialise "multi-level" JSON in VB.NET?[^]), and that was solved quickly. But I followed the steps to repeat that with yet another JSON string, and it's...
12 May 2015 by James Gordon
hey guys! So I have been working on a project and it's 99% done,all I need to do is add in a Reader for XML.I have a Serialized Data Class that gets and sets most of my objects in my program. All variables are converted to data.FirstNames etc like so... private void...
25 Feb 2014 by Jay Surendranath
1. Try a HttpClient instead of WebClient. It can read and return a string and you don't have go through the trouble of using a memorystream.2. The Json I received from this api is as follows: {"results":[...list of GoogleImageUrls..]} So create a type say ImageResults that has a...
7 Jul 2015 by Jesse Cortis
Currently working on a program in vb.net that uses JSON.Net to read the destiny JSON files.This is the JSON file.{ "Response" : { "data" : { "membershipId" : "4611686018444289561", "membershipType" : 2, "characters" : [{ "characterBase" :...
24 May 2018 by Jinto Jacob
there are many reason for this exception. Please review the stack trace for more information about the error and where it originated in the code. there is a detailed description available ... click here to visit the link...
19 Nov 2013 by Jocelyne El Khoury
I have the following json:{"Header": {"MCC": "415","FO": "0","REGID": "5" },"Contacts": [{ "NAME": "jocelyne", "MO": "70123456"},{ "NAME": "eliane", "MO": "03123456"}] }I have 2 clients: one client is giving me this json in this order, the second...
4 Apr 2017 by Karthik_Mahalingam
public class jCount { public jPlace[] count { get; set; } } public class jPlace { public int first { get; set; } public int second { get; set; } public int third { get; set; } } public ActionResult...
30 Jan 2015 by kavaan
i create a program which serialize a object and send to serverwhen i want deserialize this object :System.Runtime.Serialization.SerializationException: Unable to find assembly 'K1Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. at...
30 Jan 2015 by kavaan
but i dont use assembly or dll file...
17 Jan 2015 by Kornfeld Eliyahu Peter
Read the help carefully: http://james.newtonking.com/json/help/index.html?topic=html/T_Newtonsoft_Json_JsonConvert.htm[^]This line:d = JsonConvert.DeserializeObject(json);should be written like this:d = JsonConvert.DeserializeObject(json);
5 Aug 2015 by Kornfeld Eliyahu Peter
The problem is that your class declaration does not fit the XML format...What your code is expecting is a group of League nodes enclosed in a League node to form a kind of array: ... ... ...Now, you can change the structure of your XML to...
7 Oct 2019 by ksk
TestInfo node in the JSON does not match to the property TestInfoCollection. JsonConvert.DeserializeObject can leave reference type member properties null during deserialization without [JsonProperty] attribute on the property. Try this: 1. Synchronize the property name in the class and in the...
28 Apr 2015 by Leo Chapiro
Basically take a look at this answer:Use XML reader instead of XML dom. XML dom stores the whole file in memory which is totally useless: XmlReader ClassYour second question:Quote:How to use/access "private ATXARPACKAGE[] aRPACKAGESField" Why have you made this variable...
9 Dec 2016 by Luiey Ichigo
Hi,How to retrieve data from json file that have multiple line of data? Currently what I'm trying can be refer in "What I've tried"Below are the sample data:-[{ "DataType": "Spectre_DT", "HostName": "spectrum", "Listener": "c", "Timestamp":...
9 Dec 2016 by Luiey Ichigo
I have feel so bad where every time I post for question that I've been searching quite some times, I found the way for my own questions.To read the original format that been supplied by client:-{ "DataType": "Spectre_DT", "HostName": "spectrum", "Listener": "c", "Timestamp":...
21 Jul 2022 by Luis M. Rojas
I have the following code to connect to a Json on a server. I can connected and read the file succesfully. But i just want now to extract some fields, really i am stocked: I don't know even i have seen at lot examples (Including one in this...
13 Feb 2014 by Maarten Kools
Android JSON Parsing Tutorial[^]JsonReader[^]Android JSON Parser Tutorial[^]JSON in Android - Tutorial[^]Android JSON Tutorial: Create and Parse JSON data[^]And much more to be found in Google[^]
19 Jun 2014 by Maciej Los
If you want to know the way you can serialize and deserialize custom class collection, this tip is for you.
21 Jul 2014 by Maciej Los
Here, on CP site, you'll find several articles about serialization and deserialization of XML. Please, use SearchBox[^] on the right-top corner of this site, for example: A Complete Sample of Custom Class Collection Serialization and Deserialization[^]
18 Dec 2014 by Maciej Los
Please, read my comment to the question. That makes that direct answer is impossible.I'd suggest to read these:Serialization (C# and VB)[^]XML Serialization and Deserialization: Part-1[^]XML Serialization and Deserialization: Part-2[^]
11 Oct 2015 by Maciej Los
2 notes:1) c# is case sensitive, which means that post is not equal to Post2) List(of comments) and List(of posts) is declared in wrong wayChange its declaration to:[Serializable, System.Xml.Serialization.XmlRoot("root"), System.Xml.Serialization.XmlType("root")]public class...
5 Sep 2018 by Maciej Los
On the first look, Server class must be collection (array). I'd suggest to follow instruction from: .net - Generate C# class from XML[^] to create proper set of classes with their attirbutes. Please, read my tip too: A Complete Sample of Custom Class Collection Serialization and Deserialization[^]
2 Jan 2015 by Mayank_Gupta_
XML serialization and deserialization using C#
11 Mar 2014 by mbarbac
Implementing the Repository and Unit of Work Patterns dynamically using Kerosene ORM
1 Nov 2012 by Mehdi Gholam
The XmlSerializer does not support polymorphism like you expect. Try using my fastJSON[^] project instead.
28 Apr 2015 by Mehdi Gholam
Start here : http://stackoverflow.com/questions/15772031/how-to-parse-very-huge-xml-files-in-c[^]https://msdn.microsoft.com/en-us/library/bb387013.aspx[^]
14 Mar 2015 by Member 10232616
I have been searching in many blogs and website to view the JSON data of erail.in apibut havent got any thing working. i am doing a project so i urgently need ityou can find api in: api.erail.in
16 May 2019 by Member 10536462
{ "Description": "This registry defines the events for the management processor.", "Id": "Events.json", "Messages": { "AEPSecureEraseFailed": { "Description": "Secure Erase of Intel Optane DC Persistent Memory has failed.", "Message": "Secure Erase of Intel Optane DC Persistent Memory...
17 Jan 2015 by Member 10627743
Hi When i ran the build of the code below it shows this error "Error 1 The non-generic type 'Newtonsoft.Json.JsonConvert' cannot be used with type arguments"Kindly help with an appropriate solutionClass:public class Devotion{ public string Date {get; set;} public...
23 Jan 2015 by Member 10627743
HiWhen i ran the build i got this error "Cannot implicitly convert type 'DevotionJson.Devotion' to 'string'"//This is my classpublic class Devotion{ public string Date { get; set; } public string Title { get; set; } public string Verse { get; set; } ...
13 Mar 2015 by Member 11012009
Hello.I've got SOAP service which return datetime in format like "2015-01-22T11:23:15+0100".When I run WebMethod I get System.InvalidOperationException and message says that "2015-01-22T11:23:15+0100" is not valid AllXsd value.I want to change deserialization format of datetime, but I...
20 Aug 2014 by Member 11025073
Hi I have this Xml that I have to deserialize. YYYYMMDD HHMMSS 20100630 100000 ...
20 Jul 2021 by Member 11030334
I wrote an HTTPClient (.NET Core 3.x) that returns a JSON string but when I try to Deserialize it I run into issues. Issues ranging from can not deserialize array to string or the results are null. The string itself I can view on a Quick Watch...
20 Jul 2021 by Member 11030334
SOLVED I did not want to work with an OData Json object, so I had to strip the OData header and the rest just looked like a collection of JSON docs content = httpResponse.Content.ReadAsStringAsync().Result; var outer =...
7 Dec 2016 by Member 11266633
I have an xml. I want create class for this xml, but visual studio xml to class generator give not correct code. value ///...
3 Aug 2016 by Member 12599808
why don't you deserialize your json dictonary of(string,object) and then the property of your class.Because i think so for multi level json it can not be easily deserialize because you have to make the exact structure of class for your json with exact names and their property.
9 Mar 2022 by Member 12654018
I am new on C# and also not hands on json. I want to deserialization this json data into C# objects but don't know how to deal with these guids "ae7da5d6-4024-4f7d-9221-5d2298afe650": {} in "menus" and "categories". Your help will be appreciate. ...
16 Oct 2016 by Member 12794117
Hi,I am very new to web development and I am developing a web app using ASP.NET MVC 5.I have a requirement to deserialize a json string and store the values in C# ObjectsThis is how my JSON looks like{ "spellCheckQuery": "abc*", "searchStatus": "OK", "results": [ { ...
18 Sep 2017 by Member 13229879
I got deserializing working with single element. But when I have array of xml elements, my code is not working. Below is my code What I have tried: blue sedan ...