Linked Questions

0 votes
0 answers
145 views

I have taken the code from this example and changed a few things: remove the custom constructor and hardcode the CanConvert type. removed the converter from the calls JsonConvert.SerializeObject() ...
Louis Somers's user avatar
  • 3,030
1 vote
0 answers
27 views

I have the following classes: public class Base { } public class A : Base { public Base AField { get; set; } } public class B : Base { public int I { get; set; } public int I2 { get; set;...
xnsc's user avatar
  • 145
312 votes
12 answers
214k views

Is this valid json? { "a" : "x", "a" : "y" } http://jsonlint.com/ says yes. http://www.json.org/ doesn't say anything about it being forbidden. But ...
clamp's user avatar
  • 34.2k
77 votes
11 answers
154k views

In my web app I'm using Newtonsoft.Json and I have following object [Newtonsoft.Json.JsonObject(Title = "MyCar")] public class Car { [Newtonsoft.Json.JsonProperty(PropertyName = "name")] ...
user2034092's user avatar
15 votes
1 answer
23k views

I'm deserializing an object using Json.NET that contains a private field of type Guid and a public property for that field. When the value for my Guid is null in my json I want to assign Guid.Empty to ...
Adrian Buzea's user avatar
17 votes
1 answer
9k views

I have a JsonConverter for my class DataType. I would like to do some special handling when plain string used in Json as the value of a property of type DataType. In the case where the value is a "...
j_maly's user avatar
  • 1,121
7 votes
1 answer
4k views

I use the following in my Web API project's Startup.cs to JSON-serialize Enums into strings: // Configure JSON Serialization var jsonSerializationSettings = GlobalConfiguration.Configuration....
orad's user avatar
  • 16.2k
4 votes
1 answer
4k views

I have a need to format the output json of a decimal to a currency, with the culture specified my the object I am serializing, the object could be nested so I cannot preset the option in the ...
Bob Vale's user avatar
  • 18.5k
8 votes
1 answer
2k views

I am writing a Cmdlet and need to pass object structures into an API client that may contain PSObjects. Currently, these serialise as a JSON string containing CLIXML. Instead, I need it to be treated ...
felixfbecker's user avatar
  • 2,391
4 votes
1 answer
4k views

I have below interface: public interface IInterface<out M> { M Message { get; } string Str { get; } } And its implementation: public class Implementation<M> : IInterface<M> {...
AbbasFaisal's user avatar
  • 1,490
6 votes
2 answers
1k views

I need to convert my class to JSON and I use Json.NET. But I can have different JSON structures, like: { name: "Name", type: "simple1", value: 100 }; or { name: "Name", type: { ...
Pepo's user avatar
  • 155
1 vote
1 answer
2k views

My requirement is use JsonProperty during de-serializing and ignore JsonProperty during serialization. My model, [JsonConverter(typeof(JsonPathConverter))] public class FacebookFeed { public ...
Imran Qadir Baksh - Baloch's user avatar
3 votes
1 answer
3k views

I'm trying to achieve roughly what's described here: Recursively call JsonSerializer in a JsonConverter In short; To examine a value being deserialised, then either consume it in my own code, or ...
Basic's user avatar
  • 26.8k
1 vote
2 answers
2k views

I want to slightly tweak serialization result in a non-intrusive way. For example, I want this class: class A { int va; } to be modified like this { va: value } -> { va: value * 2 } So I tried to ...
user2771324's user avatar
3 votes
2 answers
862 views

I'm after a generic method that allows me to modify the JSON of an object being returned to the client, specifically the removal of certain properties in returned objects. Similar to what is suggested ...
Aleks's user avatar
  • 1,689

15 30 50 per page