3
I’m having a problem to be able to serialize an object (a list of a class with approximately 5000 items).
I am using JSON.NET to generate the Json string but it is getting the following problem, in the middle of it is a text like this:
,{"State":0,"DataAlteracao":null,"Id":0,"IdDadosRastreamento":0,"CodigoPeriferico":"0","ValorPeriferico":"0"}
,{"State":0,"DataAlteracao":null,"Id":0,"IdDadosRastreamento":0,"CodigoPeriferico":"0","ValorPeriferico":"0"}
,{"State":0,"DataAl:..."0","ValorPeriferico":"1840"}
,{"State":0,"DataAlteracao":null,"Id":0,"IdDadosRastreamento":0,"CodigoPeriferico":"0","ValorPeriferico":"1380"}
,{"State":0,"DataAlteracao":null,"Id":0,"IdDadosRastreamento":0,"CodigoPeriferico":"0","ValorPeriferico":"62"}
Note in bold that he cut the name of the tag as well as put "..." and then proceeded to create the file normally.
does anyone know what this problem might be and how can I solve it? the code to perform serialization is as follows:
string jsonReq = Newtonsoft.Json.JsonConvert.SerializeObject(request);
Where request is the list with 5000 positions.
You are looking directly at the result of
jsonReq
or are you handling this string later? Also, this request object is what? Is it a list of a typed class or are you using an internal serializer in the class?– rodrigogq
Rodrigo a jsonReq I write directly on an Httpwebrequest, the request is a class that has two Authdata properties: {} and a Authorship: [], which is the array that has 5000 positions. The goal is to realize the consumption of a Rest api.
– Lucas Santos
People found that json is actually generating normally, the problem is in transmitting via POST to the API Url, the file. json being generated has 12 megabytes, is there any configuration I have to do in the winforms app.config or Asp.net web.config or IIS itself to be able to do this post? what you advise?
– Lucas Santos
Look I don’t know exactly why the result is so great. Ideally you would pass filter parameter or at least pagination. Ideal resquests should not exceed a few kb. The rest is paged by the customer. This will avoid too much timeout, server time and, in case of crashes, the client requests only the required page.
– rodrigogq
Rodrigo I was able to locate in the Microsoft doc the resolution, in my case this list would not have problems in being large because it is a transmission via internal network company, is a service that keeps obtaining the tracking data of vehicles, and enters in batch these records in the bank
– Lucas Santos