Click here to Skip to main content
15,845,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I am trying to serialize List<class> 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 help me out to set max length for NewtonSoft JsonConvert.Serialize()?

What I have tried:

Here is my work.

dataTable = GetProduct();
  List<Class1> list = new List<Class1>();
  for (int i = 0; i < dataTable.Rows.Count; i++)
      list.Add(new Class1
          ID = dataTable.Rows[i]["ID"].ToString(),
          BaseClass = new BaseClass
              CreateDate = dataTable.Rows[i]["CreateDate"].ToString()
  string jsonString = JsonConvert.SerializeObject(list);

Thanks in advance
Updated 19-Jun-18 21:56pm
OriginalGriff 20-Jun-18 2:50am    
I've checked very carefully, and it isn't urgent at all - it isn't even on anybody here's "toDo" list!
All that your stressing the urgency does is to make us think you have left it too late, and want us to do it for you. This annoys some people, and can slow a response.

Now stop and think about what you are asking. Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
So when you say "missing some data" we have no idea what data might be missing, or what data you originally fed into the collection. So go back, show us what data you put in, what data you got out, and what you expected to get out - we have no idea.
Use the "Improve question" widget to edit your question and provide better information. And delete the urgency while you are there...
Chirag Sudra 20-Jun-18 2:56am    
Hi OriginalGriff,

I have update my question. Please go through it and guide me.
itsmypassion 20-Jun-18 2:59am

Check above link
Chirag Sudra 20-Jun-18 3:03am    

I have checked this link, but it is for web based application. I am trying in Windows Service project, so that won't work in here. Thanks
Mehdi Gholam 20-Jun-18 4:26am    
Serializer do not replace strings with three dots (...) you are possibly seeing that in the debugger!

In any case write it to a file to make sure File.WriteAllText("json.txt", jsonString);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900