Questions tagged [datacontractjsonserializer]

DataContractJsonSerializer is a .NET component that makes it possible to directly serialize .NET objects into JSON data and to deserialize such data back into instances of .NET types.

DataContractJsonSerializer is part of the Microsoft (version 3.5 onwards). It makes it possible to directly serialize .NET objects into data and to deserialize such data back into instances of .NET types.

As with (with which it shares an abstract base class XmlObjectSerializer), DataContractJsonSerializer is intended to serialize data contract types, thus appropriate data contract attributes may be applied to control the serialization of objects from and to JSON.

188 questions
0
votes
0 answers

Encountered unexpected character ‘<’” error serializing in DataContractJsonSerializer.ReadObject(stream)

we're sending HTTP request to Bing maps with address details to get back the address map point. The response of the HTTP request is read as stream async, this stream is then deserialized to Bing response format. When I deserialize, I'm getting this…
Marwan
  • 57
  • 12
0
votes
2 answers

XmlException: Encountered an unexpected character '

Hello everyone I switched to Json serialization, serialization work perfectly this time the problem come from deserialization I have a exception ... the error: XmlException: Encountered an unexpected character…
NEOX
  • 1
  • 3
0
votes
1 answer

Can I map a JSON element "@somename"?

I’m targeting .net framework 4.7 with a winforms application. I started by following this article https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/console-webapiclient so I am using DataContractJsonSerializer. I’m trying to learn about a…
AlecJames
  • 11
  • 4
0
votes
0 answers

C# save to json file using DataContractJsonSerializer

I want to save the data to the JSON file. Using many examples on the internet, I tried to do it, but it still does not…
0
votes
0 answers

DataContractJsonSerializer stringifies DateTime values inside dictionaries during deserialization

I need a JSON serializer/deserializer that comes with .NET. I cannot use Newtonsoft Json.NET. As far as I know, that leaves me with JavaScriptSerializer and DataContractJsonSerializer. JavaScriptSerializer didn't work properly, because it insists on…
0
votes
0 answers

ObjectToJson thorwn System.OutOfMemoryException

I use this construction. public static string ObjectToJson(TObject obj) { try { using (MemoryStream memoryStream = new MemoryStream()) { DataContractJsonSerializer ser = new…
0
votes
2 answers

DataContractJsonSerializer Deserialization problem

I need to De-serialize Json array which is given bellow .... [ { "GeoType": 1, "ID": "2650f7d2-7a5e-4b63-856c-07600fa2a854", "Name": "Afghanistan", "CapitalCity": null, "CountryBoundaries": null, …
0
votes
0 answers

Keep JSON Object as String while Serializing with DataContractJsonSerializer

Currently, I am receiving a dynamic JSON response from an API which I am trying to parse. An example of the JSON that is received looks as follows: { "data": [ { "Id": "XXXXXXXXXXXXXXXXXXXXXXXX", "IsActive": true, …
0
votes
1 answer

Controlling object creation when deserializing using DataContractJsonSerializer

I am using DataContractJsonSerializer to serialize/deserialize my object to/from JSON string. My object contains a Dictionary data member, and I want to make this dictionary case insensitive after deserialization. Currently, after…
codewarrior
  • 723
  • 7
  • 22
0
votes
1 answer

how to serialize and deserialize a tuple

How to serialize a JSON to tuple within F# (and vice versa)? JSON Schema { "name": "test", "type": "document", "id": "e3c7373c-f4bc-4ffa-9a01-7c7d9f83e4cf" } Tuple let document = ("test", "document",…
App2015
  • 973
  • 1
  • 7
  • 19
0
votes
0 answers

Serializing JSON with DataContractJsonSerializer in C# gives trailing null characters (\0)

When serializing a JSON I get trailing null characters which makes my unit test fail. The serializer looks like this: public static string SerializeJSON(T ObjectToSerialize) { DataContractJsonSerializer serializer = new…
Erik
  • 21
  • 4
0
votes
1 answer

ASP.NET MVC controller losing a day on conversion

I'm sending some data from a local application to another one (ASP.NET MVC). The data is an array of DTOs. I am testing this on my local machine. The local application is a Web Forms and is sending the data using a service. I do not use…
CristisS
  • 1,103
  • 1
  • 12
  • 31
0
votes
1 answer

Correct DateTime format for DataContractJsonSerializerSettings

Using 4.5 According to a requirements of a project already build, using Newtonsoft.Json in one side and DataContractJsonSerializer in other side of the server. I tried already two different configurations found here in order to parse DataTime…
Jonatan H.
  • 57
  • 1
  • 1
  • 9
0
votes
1 answer

De-serialize JSON return empty data

I use api url to get json response http://localhost/WaWebService/Json/NodeDetail/Demo/SCADA_NODE_DEMO Using Postman software I verify there is response { "Result": { "Ret": 0 }, "Node": { "ProjectId": 1, …
Salman Mushtaq
  • 341
  • 4
  • 23
0
votes
1 answer

DataContractJsonSerializer not working

I use the DataContractJsonSerializer to convert a JSON string into a class, but always return an empty object. I tested the string with the' JSON Viewer' extension in Notepad, is valid. Searched for a bug for a long time and compared other…