Click here to Skip to main content
15,892,768 members
Everything / Serialization

Serialization

serialization

Great Reads

by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
by Massimo Fabiano
I know that "returning DataSets from WebServices is the spawn of Satan" but...
by Sheshnath Kumar
This article will find out a solution to serialize/deserialize object by reference at server and client, also will serialize/deserialize objects having circular references.
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.

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 Michael Sydney Balloni
The world is JSON-in, JSON-out, but perhaps we can do better in some situations with our old friend CSV
by honey the codewitch
Creating an application that can run once, but then accept command line args from subsequent runs
by QxOrm
QxOrm C++ library: Persistence (based on QtSql Qt library) - Serialization (based on boost::serialization library) - Reflection (introspection)

All Articles

Sort by Updated

Serialization 

29 Aug 2023 by Member 15872449
I tried using function capnp::writePackedMessageToFd(fd, builder) to serialize C++ message and send it as packet to the file descriptor. Using the above function in my code gave me runtime Exception. Code: #define...
4 Aug 2023 by OriginalGriff
Quote: CMake Error at src/kj/CMakeLists.txt:82 (target_compile_features): target_compile_features The compiler feature "cxx_generic_lambdas" is not known to CXX compiler We can only guess, but a good possibility is that you are using a different...
4 Aug 2023 by Member 15872449
I want to use Cap'n Proto library for serialization in my Visual Studio 2013 Project,but I couldnt find any site to download either the binary or source zip. Kindly provide the site to download the same. What I have tried: I tried using cmake...
4 Aug 2023 by Richard MacCutchan
Quote: Kindly provide the site to download the same. The link for downloading is provided on the site that you linked to in your question. Quote: I tried using cmake to build visual studio 2013 solution but it is throwing errors,probably...
21 Feb 2023 by Member 14779968
Currently I have the following Json which I converted to plain object C# classes JSON: { "matchActionsReasons": [ { "name": "False positive", "value": -2147483648 }, { "name": "Acceptable risk", "value":...
2 Feb 2023 by Akshay malvankar
I stored images in database in base_64 format. Fetching that data from a controller to html using Ajax. While fetching record from in controller, I get the following error in custom filter exception: Error during serialization or deserialization...
2 Feb 2023 by Dave Kreskowiak
First, storing images in the database as anything other than binary is just going to make the image data quite a bit larger than if you just stored the bytes in a binary field, especially using base-64 encoding. Next, wrapping all that in a json...
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.
29 Dec 2021 by Juan Pele
Hi. I need to build an xml like this MM9 JKS FFES The "element" attribute is repeated several times with the same name. What...
29 Dec 2021 by Chris Copeland
Take a look at this XML serialization documentation page[^]. As Richard mentioned in his comments, you can use an XmlArrayItem attribute to indicate a collection of values. Ie. public class Dimension { [XmlArrayItem("element")] public...
17 Aug 2021 by Adam Aug2021
Thanks for the help all. Turns out all I had to do was switch from xml to text (ie. xml_oarchive to text_oarchive). Not sure what happened there but I don't have the time to keep fiddling around with it as the beginning of the semester is closing in.
17 Aug 2021 by Adam Aug2021
I currently have a class that uses a pointer vector to another class. Everything has worked fine until I began implementing boost serialization. On the first run with the program, everything works fine and appears to save the data into the .xml...
17 Aug 2021 by Greg Utas
That's a very generic error that doesn't say why abort was called. But press Retry and use the debugger to find the problem. If you don't know how to use a debugger, Visual Studio has lots of documentation about it. Using a debugger is...
27 Nov 2020 by Sacha Barber
404 points to unauthorized, I would download Postman and try it in there 1st. Try that before code
27 Nov 2020 by xhon
I'm on a proxy and I get a WebException while calling a method which should return HTTP response in JSON format. The error is the following: Server Error in '/' Application. 404 Description: An unhandled exception occurred during the execution...
8 Nov 2020 by Richard Deeming
Either remove the DefaultValue attribute, or override the default value when you serialize to XML: XmlAttributes.XmlDefaultValue Property (System.Xml.Serialization) | Microsoft Docs[^] public XmlSerializer CreateSerializer() { var...
8 Nov 2020 by .Net Perfect Dev
Hello, I try to serialize a n object to xml file.this object containt a property length [System.Xml.Serialization.XmlAttributeAttribute()] [System.ComponentModel.DefaultValueAttribute(1D)] public double Length { ...
2 Nov 2020 by Gerry Schmitz
You can't serialize a collection directly; it needs a "parent" / root. e.g. (in c#) [DataContract()] public class FengShuiStorage : IExtensibleDataObject { public ExtensionDataObject ExtensionData { get; set; } ...
2 Nov 2020 by N. Henrik Lauridsen
Hi, I need help on serializing /deserializing a class. My class: Public Class Scanner Public Property ScannerID As String Public Property ScannerText As String Private Sub New() ' Vigtigt ellers er det ikke muligt...
2 Nov 2020 by Richard Deeming
Plenty of examples in the documentation: Examples of XML Serialization | Microsoft Docs[^] Dim xsSerialize As New XmlSerializer(GetType(List(Of Scanner))) Using fs As Stream = IO.File.OpenRead(path) Return...
11 Jun 2020 by VICK
I am saving a field value as DatetimeOffset in Mongodb via C# driver which is being saved in the db as "createdAt" : [ NumberLong(637166528776997165), NumberInt(0) ] But when trying to get it back its not...
22 May 2020 by RickZeeland
Try this code generated by JSON Utils: Generate C#, VB.Net, SQL Table, Java and PHP from JSON[^] public class Content { public string Type { get; set; } public string Campaign { get; set; } public string...
22 May 2020 by Member 8087552
This should be a simple issue. I have a data class, and json data, but I cant find a way to change the strong into a json object. All help would be appreciated. Here is the string ...
4 May 2020 by Michael Sydney Balloni
The world is JSON-in, JSON-out, but perhaps we can do better in some situations with our old friend CSV
1 May 2020 by honey the codewitch
Creating an application that can run once, but then accept command line args from subsequent runs
3 Apr 2020 by OriginalGriff
Because the syntax you are using is trying to construct a List and assign properties of that list. What you need to do to supply new instances of the MatchActionsReason class and assign those properties: matchActionsReasons = new...
31 Mar 2020 by Member 14779968
I have the following Json and I have converted to classes Json : { "schedule": { "afterStartMinutesBase": 0, "beforeStartMinutesBase": 0, "scheduleType": 2, "id": "00000000-0000-0000-0000-000000000000", "currentSchedule": {...
27 Mar 2020 by phil.o
You do not serialize the controls themselves, you just serialize the information needed to (re)build them.
27 Mar 2020 by patrickb123
I'm new into C# and would like to know how I can Serialize and Deserialize dynamically generated controls in a c# UserControl. If anyone could help me, i'll be very thankful. Thank you ! What I have tried: I have successfully done this in...
23 Mar 2020 by Mahesh Pratap Singh
You need to study singleton pattern : Singleton pattern [^] Understand this and modify it to return two objects as per your requirement. For your code defaultModel and modelForUpdate should be static. You also need to include a private...
23 Mar 2020 by Member 14779968
Hello I am doing functional API testing. This error occurred when I am trying to serialize my json payload. When I try to run my test I get the following error "The active test run was aborted. Reason: Test host process crashed : Process is...
23 Mar 2020 by MadMyche
1. What you have is already serialized; are you sure you did not mean DeSerialize? 2. You don't have duplicate properties, you have an array of similar objects Newtonsoft can be used for this to convert the JSON to a JArray, which can then be...
23 Mar 2020 by Member 14779968
I have a JSON that has id and parentId twice. How do I serialize this. Here is my json [ { "id": -2147483639, "parentId": 37 }, { "id": -2147483636, "parentId": 35 } ] I have my Model class where I am using...
23 Mar 2020 by Richard Deeming
You don't have one object with the same property twice; you have an array containing two objects, each of which has the id and parentId properties once. Serialize a list of TagModel objects, and you should get the expected JSON output. ...
24 Jan 2020 by MadMyche
You could use a WHILE loop to redo this via a UPDATE on JOIN query. This is a functional version of this; you may be able tweak a little more performance out of it, but it does give the same results as your cursor based varietyDECLARE @DateWork DATE = (SELECT Min(Eff_Date) FROM #transfers)...
24 Jan 2020 by Member 12127164
How can I avoid use cursor to implement the following? I read that it can be done with CTE but I didn't get it working with the same result. In the example I am using two tables, the first one is the holders table containing a list of people and the transfers table where each transfer indicates...
2 Dec 2019 by Ashutosh Gpt
serialize in this way and it works var xmlSerializer = new XmlSerializer(typeof(myObject)); using (var xmlStream = new MemoryStream()) { xmlSerializer.Serialize(xmlStream, root); xmlStream.Position = 0; var xmlDoc = new...
2 Dec 2019 by Member 14576893
I have serialized my object to write to a file: public void writeConfig() { StreamWriter write = new StreamWriter(@"C:\users\public\documents\_myConfig.xml"); XmlSerializer serialObject = new XmlSerializer(typeof(myObject)); serialObject.Serialize(write, this); write.Close(); } It...
2 Dec 2019 by RickZeeland
Maybe you can try binary serialization, see answer here: c# - What are the differences between the XmlSerializer and BinaryFormatter - Stack Overflow[^] As you can see in the diagram, under Binary formatter "(deep serialization)" is mentioned.
1 Dec 2019 by Aishwarya Hegde
This should be possible however I have searched extensively and have found no answers to this, using WCF ISerializable interface concept. Hopefully the experts can help. Any documentation I have read only refers to info.AddValue(...) concept similar to the ones in...
1 Dec 2019 by Maciej Los
Seems, you don't understand what Serialization[^] is... An object to serialize/deserialize have to have at least one public member. But Class2 has got none public member! See: ISerializable Interface (System.Runtime.Serialization) | Microsoft Docs[^] void Main() { Class2 t = new Class2();...
11 Nov 2019 by OriginalGriff
First off, your classes don't entirely match the JSON: if you add the appropriate curly brackets to your data to make it "valid JSON" and run it through a class generator: json2csharp - generate c# classes from json[^] then you get a load of "__invalid_type__" classes generated which means that...
11 Nov 2019 by Member 14067523
i have a json response this "data": { "123456": { "rtc": { "121": { "rpc": { "2342_R": [ { "contract_type": "b2c", "egc":...
27 Aug 2019 by Richard Deeming
The problem seems to be that you don't have a wrapping element, so the array attributes are ignored. If you had: then your code would work. Without the wrapping element, it looks like...
27 Aug 2019 by C Pottinger
Hello folks. I can really use some help here. What I am attempting to do is to create an XML serializer that can handle a class that has several derived subtypes. I already know the basics of doing this: I wrote this blog entry to help me remember how. But now, I am diving a little deeper and...
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...
23 Jul 2019 by OriginalGriff
Look at what you are doing: string json = JsonConvert.SerializeObject(c1, Formatting.Indented); File.WriteAllText(path_combined, json); string json2 = JsonConvert.SerializeObject(c2, Formatting.Indented); File.WriteAllText(path_combined, json2); WriteAllText does what it says: creates a new...
23 Jul 2019 by Danny96
EDIT: I fix the previous errors, I understand my problem with the code is related to writing a blank file; when I click my button to set values to write a file; It says my "c1" object is empty. System.NullReferenceException: 'Object reference not set to an instance of an object.' at this...
22 Jul 2019 by OriginalGriff
Quote: But I am having error at the same line, it says access denied, I don't know why Access denied is pretty obvious: the user that the code is executing under does not have the rights to the file or folder it it trying to open. You can't fix that; it's a feature of the OS, and the only way...
17 Jul 2019 by OriginalGriff
JSON does not serialize fields - it only serialises properties, so MemberSerialization.OptIn will make no difference. Change your class: public class Class1 { public bool flag { get; set; } public bool flag2 { get; set; } public Class1() { ...
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...
17 Jul 2019 by Member 8989123
Hi. I need to deserialize a json with various colour shades to primary colour enums - Eg. Scarlet and Crimson to enum Red (0), and Teal and Lime to Green (1) - ,but can't work out how , or if it's possible. The code might look something like this: using System.Runtime.Serialization; public...
17 Jul 2019 by Member 8989123
Thanks for your help, Phil. I can see where you're going with this, but I'm unclear as to how to implement this is the context of reading a file (html get). Take the following example .This works fine for crimson cars, but I also need scarlet cars to deserialize as Red. Thoughts? using System;...
17 Jul 2019 by phil.o
According to EnumMemberAttribute Class[^], this attribute is defined as:[AttributeUsage(AttributeTargets.Field, AllowMultiple=false, Inherited=false)] public sealed class EnumMemberAttribute : Attribute This means that you cannot match several names to the same enumeration value. What you can do...
18 Jun 2019 by VDima77
Hello, all I would like to understand what is the best solution , if I would like to serialize/ de-serialize class to multiple XML files according to specific attribute For example , I have class with two properties and need to serialize them into two separate xml files . And the opposite...
18 Jun 2019 by Gerry Schmitz
You serialize an "object" i.e. Class. Doesn't matter if it's a "parent" or a "child". If the "object" is serializable as well as its children, then that "object graph" can be serialized. Whether what you are doing is actually beneficial is another matter.
9 May 2019 by Richard Deeming
You've requested a JSONP response: Using JSONP | Microsoft Docs[^] You'll need to see if you can change the URL you're calling to request a raw JSON response. Either consult the documentation for the service you're calling, or talk to the people who provide it.
6 May 2019 by Christian Graus
If you make a request and get that back, then that's what you were sent. If you know there's a prefix and you don't have access to the server code, use SubString to remove it
24 Apr 2019 by QxOrm
QxOrm C++ library: Persistence (based on QtSql Qt library) - Serialization (based on boost::serialization library) - Reflection (introspection)
4 Apr 2019 by violence666
I am new to Google protobuf. I have a vector of 3D integers. For the 3D integers, I have created a struct "RawValues". I then push this struct into the vector "Value". Here is how I have done it: //to save 3d values in vector struct RawValues { int32_t rawX ,rawY ,rawZ; }; ...
3 Dec 2018 by replaysMike
How to binary serialize your classes without having to modify them
28 Nov 2018 by Member 10434755
After taking a better look into the public key class, I realized that the class itself provides a .getstring() to serialize the public key. Afterwards, I used the following code to convert the string to public key again: ... byte[] publicBytes =pubKey.getEncoded(); X509EncodedKeySpec...
28 Nov 2018 by Member 10434755
I'm using ECIES in my code for encryption. The example in the provided website works without problem. However, I need a way to convert the keys (public and private keys) to string, serialize and deserialize them, using any tools. However, after trying gson and a few other techniques, yet I...
30 Oct 2018 by Ram R
Since you say capactiy error while posting to azure queue. If you are using Queue Storage, then the maximum limit on a message is 64KB unless you enable Blob Storage.
30 Oct 2018 by Ravi Sargam
I have a class where i pass mailmessage object with json serialser like JsonConvert.SerializeObject(mailmessage); The problem is if i add attachment to mail object i am getting error at JsonConvert else it is working fine, can anyone help me how to convert mail object with attachment into...
22 Oct 2018 by Poonam Patel 10678835
From return Table From SP then JSONArray obj = new JSONArray(); try { for(int i = 0; i
22 Oct 2018 by Member 14029425
{ "emp": [ { "employeeId": 52374, "employeeName": "Mayuresh Chaudhary", "employeePhone": 7888119073, "project": "ZENLABS_IIOT", "manager": "Vikram Samdare", "status": "inactive", "assets": [ { "assetsNo": 30003, ...
22 Oct 2018 by Vikas Hire
hello,Bellow is My Web Service written in C#.In this, I got a return value and a table from database.I want to merge it into single JSON Object/Array. How can I do it..?con.Open(); SqlDataAdapter da = new SqlDataAdapter("UpdateUserInfo2 ", con); ...
12 Sep 2018 by Dave Kreskowiak
Forms and Controls are not serializable. You have to create your own serialization scheme from scratch. This means creating a data structure to hold all of the information you want to keep track of, such as the type names of the controls you want to save, and all the data required to recreate...
12 Sep 2018 by MekVala
I have panel with multiple panel and controls in it(Kind Of Document Creating). I want to store Main Panel's state with inner panel and controls location and values as a template and load it again too. #NewToCodeProject Thank You What I have tried: I've tried serialization of main panel to...
5 Jul 2018 by Member 13888852
I have three txt files which contain the same Json data i want to read them all in c# class objects and overwrite all the objects from a textbox value in all the files at the same time in short i have these fields common in all three text files "time":"112429", "code":"R123", i want...
5 Jul 2018 by Bimal pedini
Just try to merge all the json files first and keep it in a single Json file and do Serialize and Deserialize that. bject o1 = JObject.Parse(@"{ 'FirstName': 'John', 'LastName': 'Smith', 'Enabled': false, 'Roles': [ 'User' ] }"); JObject o2 = JObject.Parse(@"{ 'Enabled': true, ...
19 Jun 2018 by Chirag Sudra
Hi, I am trying to serialize List to json but data which is return after serialzing misses some data from between and replaced with 3 dots (...). For converting object to Json I am using Newtonsoft library. After some R&D, I found out that it is the issue of json length. So can you...
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...
24 May 2018 by Shaikh Jani Ashraf
Hi I am getting the same exception when i convert the very large files data pulled from MongoDB and converted to string then to ASCII. Here is the line of code. Data = Encoding.ASCII.GetBytes(inputParameters.ToString()); where input parameters has DB data. And I have one more question is Is...
27 Apr 2018 by Peter Occil
A C# implementation of Concise Binary Object Representation, in the public domain
25 Apr 2018 by C. David Johnson
This is a STUPID solution but it works, public LoanIdentifierBase Value { set; get; } Was changed to [XmlText] public string RealValue { set; get; } public LoanIdentifierBase Value => (LoanIdentifierBase) Enum.Parse(typeof(LoanIdentifierBase), RealValue); With this the...
25 Apr 2018 by C. David Johnson
I'm working with a 3rd party file so I did not design the structure, and I'm stuck with it. For some reason all my enums are selecting the first value in the list instead of the correct one First here is my deserialization code using (var stream = new FileStream(filetoimport,...
24 Apr 2018 by Kornfeld Eliyahu Peter
I used this set of declarations and all works well: public enum LoanIdentifierBase { NotSet, AgencyCase, InvestorCommitment, InvestorContract, InvestorLoan, InvestorWorkoutCase, LenderCase, LenderLoan } public...
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.
20 Mar 2018 by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
22 Jan 2018 by saide_a
I am new in serialization. I want to know if new feature of c++11 such as what exists on type-trait and functional help me to make my serialization struct and save and load it to and from file without using any extra library. any tutorial ,comment and code would be appreciated. What I have...
22 Jan 2018 by CPallini
As far as I know there is no built-in serialization feature in C++11. I guess some new language (and library) features may help you in writing serialization code, however I'm not aware of any of them specifically introduced to make serialization easier.
18 Jan 2018 by Dirk Bahle
Tips & Tricks on de/serializing Tree View based content with XML
22 Dec 2017 by Dirk Bahle
Tips & Tricks on loading and saving WPF Tree View based content.
17 Dec 2017 by Member 13462150
I have a simple list, like this: fruitList = new FruitList(); Apple fruit1 = new Apple("red", "small"); Banana fruit2 = new Banana("yellow", "big"); fruitList.AddFruit(fruit1); fruitList.AddFruit(fruit2); My program displays this in a textbox: textbox.Text =...
16 Nov 2017 by Member 13515450
Hi!!! I was going to send a struct from a client to a server using boost::asio::async_write_some, in this case boost::serialization and boost::property_tree come to help, //boost::serialization struct blank { int m_id; std::string m_message; template void...
16 Nov 2017 by KarstenK
Your question is already answered on Stackoverflow.
19 Oct 2017 by ibrahim_ragab
using xsd.exe tool to create XML Schema (XSD) for the following file 12 08:00 09:00 10:00 11:00 12:00 13:00 14:00 ...
1 May 2017 by FranzBe
1) Well, if you look into the inner exception you see that the namespace of the xml is not known 2) To get along, I would first build a valid object, then serialize it and see how the valid serialized structure looks like. A base class that does the serialization and deserialization might help...
30 Apr 2017 by Naga Sindhura
How do I Deserialize the following xml into object. I could not recognize the mistake that I am doing and I getting the "There is an error in XML document (2, 2)" error. Could you please help me on this. Input Xml format i.e. books.xml
29 Apr 2017 by Member 12424653
I was going through the serialization and de-serialization concepts and trying to relate it with what i worked and what I understood, please correct me if i am wrong.. What I have tried: ajax call to Get data for example: $.ajax({ url:...
30 Mar 2017 by sopy7
I'm trying to pass system default proxy from windows application to windows service. While passing the value I get the below error.//Type 'System.Net.WebRequest+WebProxyWrapper' cannot be serialized. Consider marking it //with the DataContractAttribute attribute, and marking all of its...
12 Mar 2017 by Gregory Morse
Deserialization and serialization classes for JSON objects in native C++ with COM and ATL
20 Feb 2017 by ÂĦmâd Ŝâlâĥ
i get xml file from service , but i have problem when i want Deserialize to object ,, always show me root element is missing xml
20 Feb 2017 by Praneet Nadkar
Hi,The following code worked for me with your xml: string xml = "KRPA...
19 Feb 2017 by Graeme_Grant
This may help you: Convert XML to C# Classes[^]
26 Jan 2017 by Vikas Hire
Hello there's..I want to concatenate two json string.first string contains data tables records details and other string contains Count value.I get that values In data set such that.dataset ds.Tables[0]= //table records ds.tables[1]=// singale integer value (e.g....
26 Jan 2017 by Richard Deeming
Try something like this:json = JsonConvert.SerializeObject(new { contactList = ds.Tables[0], totalCount = ds.Tables[1].Rows.Cast().Select(r => r[0]).FirstOrDefault()}, Formatting.None);
9 Jan 2017 by Vikas Hire
hello,I want to get convert multiple data object into JSON string using C#.Like.. 1-I have a data table which I get from database using store procedureand 2-I have a string("userType:1") like this.I want to return both of data object (table and string) in my json String. How can I do it,...