Linked Questions
14 questions linked to/from Serialize C# Dictionary as JSON object using WCF with HTTP
214
votes
9
answers
293k
views
Specifying a custom DateTime format when serializing with Json.Net
I am developing an API to expose some data using ASP.NET Web API.
In one of the API, the client wants us to expose the date in yyyy-MM-dd format. I don't want to change the global settings (e.g. ...
209
votes
8
answers
179k
views
When to use DataContract and DataMember attributes?
I am very confused about the DataContract attribute in WCF. As per my knowledge it is used for serializating user defined type like classes. I wrote one class which is exposed at client side like this....
124
votes
6
answers
182k
views
How to set json serializer settings in asp.net core 3?
json serializer settings for legacy asp.net core applications were set by adding AddMvc().AddJsonOptions(), but I don't use AddMvc() in asp.net core 3. So how can I set global json serialization ...
92
votes
6
answers
233k
views
C# JSON Serialization of Dictionary into {key:value, ...} instead of {key:key, value:value, ...}
Is it possible to serialize a .Net Dictionary<Key,Value> into JSON with DataContractJsonSerializer that is of the format:
{
key0:value0,
key1:value1,
...
}
I use Dictionary <K,V>, ...
46
votes
3
answers
29k
views
How to serialize a Dictionary as part of its parent object using Json.Net
I'm using Json.Net for serialization.
I have a class with a Dictionary:
public class Test
{
public string X { get; set; }
public Dictionary<string, string> Y { get; set; }
}
Can I ...
34
votes
5
answers
14k
views
Make ASP.NET WCF convert dictionary to JSON, omitting "Key" & "Value" tags
Here's my dilemma. I'm using a RESTful ASP.NET service, trying to get a function to return a JSON string in this format:
{"Test1Key":"Test1Value","Test2Key":"Test2Value","Test3Key":"Test3Value"}
But ...
26
votes
1
answer
21k
views
C# JSON custom serialization
Is there a way/library that will allow me to customize JSON serialization similar to GSON custom serializers?
Here is what I'm trying to get:
this object: KeyValuePair("Age",10) myAge
will normally ...
12
votes
2
answers
15k
views
Replace WCF default JSON serialization
Is it possible to replace the default JSON serialization of WCF (I'm currently testing with the webHttp behaviour), and passing application/json as the MIME type. In particular, I don't like that by ...
8
votes
2
answers
11k
views
Configuring WCF 4 with routing (global.asax) for both http & https endpoints
I'm still a newbie with wcf and not too well informed in .net in general. I have a WCF 4 web service that uses the global.asax routing approach and very simplified web.config using the standard ...
9
votes
1
answer
5k
views
Serialize a Dictionary as JSON object using DataContractJsonSerializer
I have an [DataContract] object that has some properties and is serialized to JSON using DataContractJsonSerializer.
One of the properties is of type Dictionary<string, string> and when the ...
5
votes
1
answer
1k
views
How to return a Dictionary of custom type values as a regular JSON object from a WCF REST method?
Let's say I've got a custom type that looks like this:
[DataContract]
public class CompositeType
{
[DataMember]
public bool HasPaid
{
get;
set;
}
[DataMember]
...
1
vote
1
answer
2k
views
WCF Dictionary<string, object> serialization
I have a service that has a method like this
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ...
2
votes
1
answer
471
views
WCF DataContract: mapping JSON object to C# Dictionary
I would like to deserialize a JSON dictionary I receive from a python application via HTTP into a Dictionary in C#.
The JSON object looks like this:
{
"native_dict": {
"foo": 0,
"...
0
votes
0
answers
100
views
wcf json array with variable name not deserializing
I have created a WCF service that accepts, for example, this json:
{
"type": "despatch",
"client_ref": "ORD00001",
"date_despatched": "2015-...