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
2 answers

DataContractJsonSerializer and List

In my code I have to serialize List where IModel is the interface for concrete class Model Here is some pseudo code for them: public interface IModel { string Codice { get; set; } int Position { get; } } [DataContract] public class…
Filippo
  • 1,123
  • 1
  • 11
  • 28
0
votes
0 answers

DataConstractJsonSerializer combining two JSON files

In the Norway they have a register of organisations (brreg.no), which you can access through a webservice. If an organisation owns one or more other organisations, you can also access a list of those. Now my problem is this: I would like to create…
Jakob Busk Sørensen
  • 5,599
  • 7
  • 44
  • 96
0
votes
1 answer

DataContractJsonSerializer fails on any thread other than UI thread

In my WPF application, I have class that serializes and deserializes a given object to and from JSON. If I call the deserialization method from the UI thread it works fine. However I would like it to work in the background, and whenever it's on…
Michael
  • 177
  • 3
  • 11
0
votes
1 answer

How do DataContracts work? - Deserialize Json

I grabbed an example off of this SO question, and built my own custom Google Maps object used for deserializing the json object. Now the code works like a champ, but I just need an explanation on why/how it works. Does the serializer "try" to match…
Chase Florell
  • 46,378
  • 57
  • 186
  • 376
0
votes
0 answers

What is in an "Object" from a deserialized JSON file using DataContractJsonSerializer?

I can't find anything in the docs or in related questions. I'm trying to deserialize following json file(tile_config.json): { "tile_info": [ { "height": 32, "width": 32 } ], "tiles-new": [ { "file": "tiles.png", …
KayelGee
  • 15
  • 3
0
votes
1 answer

Deserialize multi-type JSON array using DataContracts

Currently, I have some JSON data that I am attempting to deserialize using the DataContractJsonSerializer class. However, one of the arrays in the data contains multiple types of objects. Is there a way to deserialize this data properly? I am aware…
0
votes
1 answer

How to parse a json object array containing mixed primitive types using DataContractJsonSerializer?

How can I parse the JSON object below using DataContractJsonSerializer in C#? I will need to define a class to hold the below JSON data, which includes an array of arrays of primitives of mixed types (string and integer): Body: { "status":…
user1174114
  • 178
  • 1
  • 19
0
votes
1 answer

Anonymous type in method for Deserializing json from a string to DataContract

I am trying to write an anonymous method for the purpose of deserializing Json to a DataContract. This would allow me to have something re-usable without having to write the same code for each DataContract class I wrote for each json query. The code…
Kraang Prime
  • 9,981
  • 10
  • 58
  • 124
0
votes
2 answers

Producing Json in correct format

I'm trying to produce the below Json { "retailer": "The retailer", "sites": [{ "id": "1234", "Sitename": "Microsoft", "website": "www.microsoft.com" }], "Products": [{ "Name": "Visual Studio", …
Computer
  • 2,149
  • 7
  • 34
  • 71
0
votes
2 answers

DataContractJsonSerializer deserializing List throwing error

I have a custom Exception : [Serializable] public class MyCustomException : Exception { public List ErrorInfoList { get; set; } protected MyCustomException (SerializationInfo info, StreamingContext context) : base(info,…
0
votes
1 answer

How to serialize/deserialize a DateTime stored inside an object field using DataContractJsonSerializer?

I use the following class to exchange JSON data over two ASP.NET services : [DataContract] public class Filter { [DataMember] public string Name {get; set;} [DataMember] public FilterOperator Operator {get; set;} [DataMember] …
tigrou
  • 4,236
  • 5
  • 33
  • 59
0
votes
0 answers

Unspecified type of the property when deserializing an object

I am trying to use OneSignal API. My problem isn't specific to OneSignal but I think that referencing it might make it easier to explain. OneSignal is an SAAS for delivering notifications to phones and browsers and I am trying to hook it up to my…
johnatann
  • 145
  • 11
0
votes
1 answer

Unable to Serialize Object to JSON Using DataContractJsonSerializer

I have taken the following code from https://msdn.microsoft.com/en-us/library/bb410770(v=vs.110).aspx and put it in a Visual Studio project. Program.cs using System; using System.IO; using System.Runtime.Serialization; using…
Ellipsis17
  • 85
  • 1
  • 2
  • 10
0
votes
1 answer

DataContractJsonSerializer ; ISerializable GetObjectData called with .NET but not with mono

Below is a simplified example of what I'm trying to accomplish. I have a class DoNotSerializeMe which is part of an external library and cannot be serialized. using System; namespace CustomJsonSerialization { public class DoNotSerializeMe …
Jaws
  • 121
  • 1
  • 3
0
votes
1 answer

DataMember ignored when serializing to JSON

I have added DataMemeber to my object properties to change settings when serializing to JSON, however it is not using them. I have attempted to change the name, as well as emitting default values. My reason for trying to do this is I want to ignore…