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
3
votes
1 answer

Deserialize json with array of different types using DataContractJsonSerializer

Is there a way to deserialize such json { "photos": [ 19, { "pid": 288777129, "aid": -6 }, { "pid": 286441792, "aid": -6 }, { "pid": 114893258, "aid": 34465839 } ] } with C#…
mumu2
  • 661
  • 1
  • 5
  • 15
2
votes
2 answers

prevent a propery from being serialized using a datacontractjsonserializer C#

I am using the .net datacontractjsonserializer to serialize my list of objects to a JSON string, but there are certain public properties that I don't want to serialize, how to prevent the datacontractjsonserializer from serializing these…
user1010572
  • 469
  • 1
  • 4
  • 16
2
votes
1 answer

Json deserialization of anonymous array

I would like to deserialize the following json using DataContractJsonSerializer: "coordinates": [ [ 18.008966033966707, 59.328701014313964 …
Per Kastman
  • 4,466
  • 24
  • 21
2
votes
2 answers

How to serialize class that derives from class decorated with DataContract(IsReference=true)?

I have class A that derives from System.Data.Objects.DataClasses.EntityObject. When I try to serialize using var a = new A(); DataContractJsonSerializer serializer = new…
theateist
  • 13,879
  • 17
  • 69
  • 109
2
votes
2 answers

Windows Phone - Background Task - Broken at DataContractJsonSerializer.WriteObject

I am using Background Task in Windows Phone Mango. I need to send data to server using JSON format. But when DataContractJsonSerializer.WriteObject function is executed, nothing happens thereafter. Has anyone experienced the same with Background…
2
votes
3 answers

How to pass none english letters to Json

I'm working on a Xamarin Forms app for Android & iOS I'm trying to figure out how to pass none english letters to Json file. My language is Swedish and whenever I use characters like (Å, Ä, Ö) the app crashes. So how do I fix this please…
Jaser
  • 245
  • 1
  • 7
  • 21
2
votes
1 answer

How to deserialize JSON returned by WCF Data Service (OData)

An external OData Service returns the following during a POST operation (for a service operation): { "d" : { "__metadata": { "uri": "http://dd-1620/ServiceData.svc/Customers('1001')", "type": "DataModel.Customer" }, "MasterCustomerId": "1001",…
2
votes
1 answer

How do I format a DateTime structure so that it matches the format used by DataContractJsonSerializer?

When I serialize the current time as a DateTime using the DataContractJsonSerializer I get the following 1307654074638-0500. I'd like to generate my own JSON that could be deserialized by the DataContractJsonSerializer, but I can't figure out how to…
ScArcher2
  • 85,501
  • 44
  • 121
  • 160
2
votes
1 answer

How to serialize JSON string containing date and time property using DataContractJsonSerializer?

we are trying to serialize a JSON object [as a string] into a custom class. While we rather not use any third-party packages such as Newtonsoft.Json or Json.NET, we tried to utilize DataContractJsonSerializer. The JSON object contains a DateTime…
2
votes
1 answer

.NET DataContractJsonSerializer, Nested collections throwing me for a loop

I'm working on a class to get the Latitude and Longitude of an address by 3 different providers (just for comparison sake). Note, this might look like a lot to look at, but some info is just there for reference if you want. Data below the
is…
Chase Florell
  • 46,378
  • 57
  • 186
  • 376
2
votes
1 answer

Why cant I serialize a property that has a private setter (C#, json)

I'm using dotnet core 2.1 and made a helper to serialize from and to JSON. It's built on System.Runtime.Serialization.Json that ships with dotnet core. I don't want to use JSON.NET lib for some reasons (it doesn't matter here) I'm facing a bug I…
kipy
  • 527
  • 4
  • 10
2
votes
1 answer

DataContractJsonSerializer: Serializing a class with an interface property

I am trying to serialize a Class like this: [DataContract] public class GenericFlow { [DataMember] public ISource Source { get; set; } [DataMember] public IList Filters { get; set; } } When i seralize an instance of this…
Bolo
  • 41
  • 4
2
votes
1 answer

Deserialization from JSON into List of Objects

I am attempting to deserialize a json file into a List of Objects. The JSON file requires that I use UTF8. I am attempting to do it this way below. FileStream reader1 = new FileStream(fileName, FileMode.Open, FileAccess.Read); StreamReader…
2
votes
3 answers

Constructors Not Called On Deserialization

Various places I've been reading have pointed out that on deserialization, the .NET Framework makes a call to FormatterServices.GetUninitializedObject, in which constructors are not called and field initializers are not set. If this is true, why is…
Wes P
  • 9,622
  • 14
  • 41
  • 48
2
votes
1 answer

EnumMemberAttribute Value is ignored by DataContractJsonSerializer

This is my code: [DataContract] // (Name = "Type")] public enum Purpose { [EnumMember(Value = "definitionTarget")] DefinitionTarget = 0, [EnumMember(Value = "definitionSource")] DefinitionSource = 1, [EnumMember(Value =…
Vadim Berman
  • 1,932
  • 1
  • 20
  • 39
1 2
3
12 13