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

Parse Dictionary in JSON using DataContractJsonSerializerSettings w/o using header class

I'm parsing a JSON string into a list of items. The json text has the items organized as a dictionary under a parent item "material". The below code works. Is there a better way to do this where I don't need the MaterialHeader class? public class…
Andrew
  • 521
  • 7
  • 18
0
votes
0 answers

Is there any way of parsing a JSON string without deserialising it?

I am calling a web service that returns JSON with a duplicate node in some circumstances, providing output similar to this: { "shipments": [ { "id": "A000001", "name": "20141208 140652", "type":…
0
votes
1 answer

JSON serialize/deserialize with Dictionary using .NET DataContractJsonSerializer serializer

First.. I'm not interested in JSON.NET or any other parsers. Only DataContractJsonSerializer I have to work with structures I get and send to REST API and they look like so: { "records": [ { "attributes": { …
katit
  • 17,375
  • 35
  • 128
  • 256
0
votes
1 answer

Entity framework with Uint DataContractJsonSerializer

I have an api which I call that return JSON. This I deserialize to objects using DataContractJsonSerializer. My JSON can have uint values ranging higher than int.MaxValue so I need to have a uint property on my classes to avoid exception. This class…
Evelie
  • 2,919
  • 2
  • 14
  • 21
0
votes
2 answers

Unable to serialize System.Net.Mail.MailAddress to Json

I Have a email class as public class EmailInfo { public MailAddress SenderEmailAddress { get; set; } public MailAddressCollection ReceiverEmailAddress { get; set; } public MailAddressCollection CCEmailAddress { get; set; } public…
Pankaj
  • 1,446
  • 4
  • 19
  • 31
0
votes
0 answers

How to parse the list of objects using DataContractJsonSerializer?

How to serialize list of objects using DataContractJsonSerializer? When I tried to parse the following json string, I got InvalidCastException "[{\"name\":\"Adam\",\"age\":\"null\"},{\"name\":\"James\",\"age\":\"null\"}]" I have been using the…
0
votes
1 answer

Type is not serializable because it's not public datacontractserializer

I am new to wcf and windows phone 8 app and calling wcf service(other dev) and trying to deserialize the data it works fine sometimes but most of the times it gives me error "The data contract type …
0
votes
2 answers

How to Serialize a JSON Parameter list of varied type and without names

I need to post a request to a server containing the following JSON. I want to use DataContractJsonSerializer and DataContract, DataMember attributes on the classes representing a request such…
TrevorB
  • 43
  • 5
0
votes
1 answer

JavaScriptSerializer Serializer is not handling null values

In my WPF MVVM application I am getting Data from a restful WCF service in JSON format. I am de-serializing this data using JavaScriptSerializer. But this is not able to handle the null value if any. In this case I have to send some values instead…
0
votes
0 answers

DataContractJsonSerializer - deserialize to dictionary

I want to deserialize a json that I get as result of a REST query (the json string can not be changed) to a dictionary type. The json string looks something like this: { "collection": { "useful": true "attributes": { "ObjectID":…
user2717436
  • 775
  • 1
  • 10
  • 23
0
votes
1 answer

C# DataMember Serializer Ordering Opposite of Expected

According to this article, I'd expect to see the fields in my base class at the top of the list of fields when serializing to JSON. However, I'm seeing the fields at the bottom of the list. The ordering is correct within the actual class itself,…
0
votes
2 answers

Special characters, XmlException and DataContractJsonSerializer

I'm seeing XmlException occuring from the output whenever the JSON being deserialized contains characters like '@'. In the end, it still successfully deserializes it, but it bugs me not knowing what's going wrong. It also slows down debugging a lot…
Sami Rajala
  • 191
  • 1
  • 11
0
votes
1 answer

Deserializing JSON with different types for serialization/deserialization

I have a class: [DataContract] public class A { [DataMember] public B ArbitraryProperty { get; set;} } When serialized, "ArbitraryProperty" needs to be in the form of class "B": [DataContract] public class B { [DataMember] public…
Tim
  • 1,029
  • 7
  • 20
0
votes
1 answer

How to create nested JSON objects and arrays with DataContractJsonSerializer?

I want to create JSON with nested arrays and objects like this: {"orderId": "AF34235", "recipients": [{"name": "Jane Doe", "address": "123 Main"}, {"name": "Bob Doe", "address": "456 Broad"}], "sender": {"id": 123, "address": "789…
royco
  • 5,409
  • 13
  • 60
  • 84
0
votes
1 answer

DataContractJsonSerializer to deserialise Json

I am trying to deserialize a Json String. My Deserialization works up to OrderData. When I deserialize OrderData is always null and SourceData also not showing up. It's not throwing any error either. Any suggestion to get this resolved? string…
Steve
  • 1,471
  • 7
  • 19
  • 32
1 2 3
12
13