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

How to check DataContractJsonSerializer DateTime has offset value present

I have a date time receiving from DataContractJsonSerializer(webservice input).Normally the date time input will be actual local time of web service consumer, for example "2016-04-04T07:00:00.000000" but some web service consumers will pass datetime…
aj136252
  • 21
  • 2
0
votes
2 answers

.NET Append JSON to a string already serialized with DataContractJsonSerializer

I am using DataContractJsonSerializer to serialize an object to json, and then returning to the client with AJAX. I now need to serialize another object to return along with it. The problem is MSs "d" that wraps around the JSON, that stops me from…
Brett
  • 2,706
  • 7
  • 33
  • 49
0
votes
1 answer

How to remove the Key/Value from a Dictionary or KeyValuePair when using DataContractJsonSerializer

Seen some ideas in other posts, but could not get rid of the Key Value text in my json string. Have a bunch of options built in code to pass to the FLOT javascript graphing app. Dictionary type items, is giving me an issue. Using .Net 4.0, so don't…
Yogurt The Wise
  • 4,379
  • 4
  • 34
  • 42
0
votes
0 answers

DataContractJsonSerializer cannot deserialize Newtonsoft JsonSerializer

What do first 3 bytes written by JsonSerializer on the begging of stream mean and why does DataContractJsonSerializer have a problem with them? Sample: Foo foo = new Foo(); using (MemoryStream stream = new MemoryStream()) { //serialize using…
eCorke
  • 858
  • 1
  • 10
  • 24
0
votes
3 answers

Unable to reproduce NewtonSoft deserialization error locally

I'm getting following error in deserializing a json object : (Using JSON.NET) Cannot create an abstract class. at System.Runtime.Serialization.FormatterServices.nativeGetUninitializedObject(RuntimeType type) at…
Imran
  • 656
  • 1
  • 7
  • 13
0
votes
1 answer

UWP: Nested Custom Types with DataContractJsonSerializer

I am creating a nested custom type with primitive datatypes. I am having a Web APi that returns the data in JSON. using json2csharp.com, I am generating classes for the same. I have decorated the primitive datatypes in all classes with DataMember…
0
votes
1 answer

How to add save() method generically to classes that have a DataContract?

I have a class with DataContract that can be saved to a file: using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; namespace Test { [DataContract] public class Data { [DataMember] …
0
votes
1 answer

How can I implicitly serialize via DataContractJsonSerializer when creating StringContent for HTTPClient?

I have an object that I convert to json in order to send it to a web service. I added a method to the class that returns a json string public string ToJson() { return new JavaScriptSerializer().Serialize(this).ToLower(); } The…
null
  • 5,207
  • 1
  • 19
  • 35
0
votes
1 answer

Why are arrays being shown as null after serializing using DataContractJsonSerializer?

There have been a number of questions about serializing and deserializing arrays using DataContractJsonSerializer (including one from me: How can I serialise a string array to JSON using DataContractJsonSerializer?) but none seem to answer the…
0
votes
1 answer

C# - JsonSerializer - DataContract runtime error

I call for to consume json rest web service. My classes are: using System.Collections.Generic; using System.Runtime.Serialization; namespace WFAEsura { [DataContract] class JsonResponse { …
0
votes
1 answer

Accessing DataContractJsonSerializer properties via re-factored foreach loop

I have the code below. The line string content = twitterMsg.text; is creating the error 'Use of unassigned local variable' for twitterMsg. I don't seem able to access my TwitterSearchResponse.results.text fields in my…
Alex
  • 4,844
  • 7
  • 44
  • 58
0
votes
0 answers

Error Deserializing JSON data with DataContractSerializer in Silverlight 4

I am trying to deserialize JSON from a Web service to a complex object in Silverlight using the DataContractJsonSerializer. When the JSON data is minimal, I am having no issues but when the data is large, I am getting SerializationException with the…
0
votes
1 answer

Json write can not be serialized

Process: Create the Player class. Create the player List(). Add players to the list. Write a json serial file. When I click on writeJson button I receive the error: "Type `'EditPlayers.Player'` cannot be serialized. Consider marking it with…
0
votes
0 answers

Remove slashes and quotes from JSON string returned

I am using below code to convert my model class to JSON data [DataContract] public class EventList { [DataMember(Name = "success")] public int success; [DataMember(Name = "result")] public List
Sebastian
  • 4,625
  • 17
  • 76
  • 145
0
votes
2 answers

Xamarin Using DataContractJsonSerializer for Android Blank App

I am trying to use DataContractJsonSerializer but I can't seem to get a reference/namespace for it. I created my app on a .NET Framework 4.5. When I click add reference I only get the version 2.0.5.0 for System.ServiceModel