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
1
vote
1 answer
1
vote
1 answer

WCF REST service dictionary serialization

I'm having trouble with serializing dictionary in my WCF service. [DataContract] public class UserInfo { [DataMember] public Guid ID { get; set; } [DataMember] public string Name { get; set; } …
zhuber
  • 5,364
  • 3
  • 30
  • 63
1
vote
0 answers

Serialize parameters for remote procedure call

I want to design a RPC scenario. The client call is serialized using DataContractJsonSerializer. The serialized request is passed to service. Service deserializes the request and use it to invoke the native method. Service returns the result as…
konjac
  • 757
  • 8
  • 14
1
vote
0 answers

Deserializing Part Of A JSON To Dictionary using C# DataContract

I'm parsing some JSON which looks like this using DataContract. The issue that i have is parsing "ThresholdRules" as dynamic as possible. Keep in mind the objects inside "ThresholdRules" go up to 99 so having a DataMember defined similar to…
1
vote
1 answer

Problem when serializing objects with strings that contain "/"

I am using DataContractJsonSerializer to serialize an object, and to do this I am using the following function: public static string Serialize(T obj) { string returnVal = ""; try { DataContractJsonSerializer serializer = new…
KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
1
vote
1 answer

Optional fields with DataContractJsonSerializer (how to change the default)

I have been using DataContractJsonSerializer succesfully to serialize an object into json. The great thing about this is that I can work with optional fields (that may or maynot be serialized). For example [DataContract()] public class aClass { …
KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
1
vote
1 answer

JSON parsing collection of records

I've been struggling with this for long, I believe there's something wrong with my record design. MY json looks like below. I posted this earlier as a part of another question but didn't get full answer especially for this part. Each record within…
App2015
  • 973
  • 1
  • 7
  • 19
1
vote
1 answer

JSON serialization for option types

I'm running across an issue when I define a field of option type while serializing for JSON. Before works (without option) [] type Article = { [] version: string } After throws…
App2015
  • 973
  • 1
  • 7
  • 19
1
vote
1 answer

DataContractJsonSerializer with object type member

I have the following serialization method: private string Serialize(Message message) { byte[] json; using (var ms = new MemoryStream()) { var ser = new DataContractJsonSerializer(typeof(Message)); ser.WriteObject(ms,…
Xavier W.
  • 1,270
  • 3
  • 21
  • 47
1
vote
1 answer

Json Deserializing not populating properties

I'm deserializing a third party string like this: {"status":4,"errors":[{"Duplicate Application":"Duplicate Application"}]} I use my standard extension method: public static T DeserializeJson(string response) where T : class { var s =…
John Ohara
  • 2,821
  • 3
  • 28
  • 54
1
vote
1 answer

How can I Deserialize nested json with DataContractJsonSerializer?

I'm trying to deserialize json like this: { "version": 3070, "settings": [ [ "settingInteger", 0, "1513486800", { "param": "A" } ], [ …
Hirocky
  • 13
  • 2
1
vote
1 answer

Exception When Deserializing an ISO Date in JSON

I am trying to deserialize an API response to a class object. But I get the error: DateTime content 2017-11-15T10: 00: 00 does not start with \ / Date (and not ending) \ /, which is required for JSON. My Code: client.BaseAddress = new…
AllramEst
  • 1,319
  • 4
  • 23
  • 47
1
vote
1 answer

How to serialize object array with a dictionary inside

I'm trying to serialize an object array which contains a dictionary as one of its values, and I'm getting this run-time SerializationException: Type 'System.Collections.Generic.Dictionary`2 ...with data contract name…
Igor Kleinerman
  • 143
  • 1
  • 8
1
vote
1 answer

Is it possible to use the .NET DataContractJSONSerializer to deserialize a JSON file formatted differently than it would usually serialize?

I have a JSON file formatted like so, which is generated by a tool that I cannot edit: { "thing_name1": { "property1": 0, "property2": "sure" }, "thing_name2": { "property1": 34, "property2": "absolutely" …
robohobo
  • 13
  • 4