TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sangeetha k
NA
207
51.2k
How to serialise and deserialise a list in c#
Jul 13 2018 4:22 AM
Borrower result = new Borrower();
List<Borrower> brwlist = new List<Borrower>();
brwlist = new List<Borrower> {
new Borrower
{
ID = 210626,
BorrowerStatus = "",
BrwAdd1 = "Property Address line 1",
BrwAdd2 = "",
BrwCellPhoneNo = "",
Brwcity = "Palmbay",
BrwEmaillID = "",
BrwHomePhNo = "",
Brwstate = "AK",
BrwZipCode = "89874",
DateOfBirth = null,
deduction = null,
FirstName = "John",
income = null,
LastName = "Smith",
LoanID = 89191,
PropertyInfo = null,
Sequence = 1
}
};
string dres = JsonConvert.SerializeObject(brwlist,Formatting.Indented);
var brw = JsonConvert.DeserializeObject<List<Borrower>>(dres.ToString());
HttpContext.Current.Session["BorrowerList"] = brwlist;
// var b = brwlist.ConvertAll(x => Convert.ToString(x));
var res = _BorrowerController.BorrowerAddress() as JsonResult;
//string a = brwlist.ToString()
//string a = Newtonsoft.Json.JsonConvert.SerializeObject(new Borrower
//{
// ID = 210626,
// BorrowerStatus = "",
// BrwAdd1 = "Property Address line 1",
// BrwAdd2 = "",
// BrwCellPhoneNo = "",
// Brwcity = "Palmbay",
// BrwEmaillID = "",
// BrwHomePhNo = "",
// Brwstate = "AK",
// BrwZipCode = "89874",
// DateOfBirth = null,
// deduction = null,
// FirstName = "John",
// income = null,
// LastName = "Smith",
// LoanID = 89191,
// PropertyInfo = null,
// Sequence = 1
//});
// var dres = JsonConvert.DeserializeObject<Borrower>(a);
string jresult = JsonConvert.SerializeObject(res.Data, Formatting.Indented);
var dresult = JsonConvert.DeserializeObject<List<Borrower>>(jresult.ToString());
// var dresult1 = JsonConvert.DeserializeObject(a.ToString());
Assert.AreEqual(dresult,brw);
// Assert.AreEqual(dresult, (dres));
// Assert.AreEqual(dresult.BorrowerStatus, dresult.BorrowerStatus);
}
Reply
Answers (
3
)
Need Decryption for this code
Static code analysis issue of Unrestricted Upload of File