tagged [json.net]

Newtonsoft.Json.Linq.JArray to string array C#

Newtonsoft.Json.Linq.JArray to string array C# I have a JSON Array like the model is `dynamic` I want to convert `model.Users` to `string[] Users` How can I do that?

16 May at 17:9

Private setters in Json.Net

Private setters in Json.Net I know there's an attribute to handle private setters but I kind of want this behavior as a default, is there a way to accomplish this? Except tweaking the source. Would be...

31 Jul at 22:12

JSON date from tweeter to C# format

JSON date from tweeter to C# format How to format a JSON date obtained from twitter to a C# DateTime ? Here is the format of the date I receive : Can I do it with JSON.NET ?

19 Feb at 16:43

.NET Core 3.0 StringEnumConverter not serializing as string

.NET Core 3.0 StringEnumConverter not serializing as string When decorating your enum with: And serializing it with `JsonConvert.SerializeObject(myEvent)` You may notice that the enum is not serialize...

8 Oct at 14:14

Add a custom attribute to json.net

Add a custom attribute to json.net JSON.NET comes with property attributes like `[JsonIgnore]` and `[JsonProperty]`. I want to create some custom ones that get run when the serialisation runs e.g. `[J...

2 Oct at 13:45

Json.Net: JsonSerializer-Attribute for custom naming

Json.Net: JsonSerializer-Attribute for custom naming I use the `JsonSerializer` from Newtonsoft. But i want to name the json-objects by myself. I tried the `JsonObject` attribute `JsonArray` also didn...

11 Nov at 16:11

How to check if dynamic is empty.

How to check if dynamic is empty. I am using Newtonsoft's Json.NET to deserialize a JSON string: How can I check that `output` is empty? An example test case:

29 Jul at 01:41

How to combine/merge two JArrays in JSON.NET

How to combine/merge two JArrays in JSON.NET I can't figure out how to concatenate two JArrays that I got by using JArray.Parse? The order of the arrays must be preserved i.e. the first array should b...

12 Aug at 21:44

'Newtonsoft.Json.Linq.JArray' does not contain a definition

'Newtonsoft.Json.Linq.JArray' does not contain a definition I am trying this code: but line 3 gives this error, how come? How do you get this data?

24 Aug at 16:40

How to create a JSON.NET Date to String custom Converter

How to create a JSON.NET Date to String custom Converter Could someone tell me please how I can create a custom converter I know I can use JSON.NET ISODateConvertor, but what I want is specific, I jus...

18 Apr at 17:8

Web API serialize properties starting from lowercase letter

Web API serialize properties starting from lowercase letter How can I configure serialization of my Web API to use `camelCase` (starting from lowercase letter) property names instead of `PascalCase` l...

How to convert JSON to XML or XML to JSON?

How to convert JSON to XML or XML to JSON? I started to use Json.NET to convert a string in JSON format to object or viceversa. I am not sure in the Json.NET framework, is it possible to convert a str...

3 Nov at 19:14

Using JSON to Serialize/Deserialize TimeSpan

Using JSON to Serialize/Deserialize TimeSpan I'm trying to deserialize/serialize a timespan with [Newtonsoft.Json.JsonConvert](https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonConvert.h...

17 Aug at 12:9

Why ServiceStack.Text doesn't default dates to iso8601?

Why ServiceStack.Text doesn't default dates to iso8601? If I use Newtonsoft.Json.NET it defaults to iso8601 (i.e.: `2011-06-02T09:34:29+02:00`) for serializing/deserializing dates. Why ServiceStack.Te...

8 Apr at 15:58

Json.NET JsonConvert.DeserializeObject() return null value

Json.NET JsonConvert.DeserializeObject() return null value i tried to this string : ``` string _jsonObject = {\"Ad\":{\"Type\":\"Request"\, \"IdAd\":\"xxx@xxx.com\", \"Category\":\"cat\", ...

17 Jun at 14:14

How can I beautify JSON for display in a TextBox?

How can I beautify JSON for display in a TextBox? How can I beautify JSON with C#? I want to print the result in a TextBox control. Is it possible to use JavaScriptSerializer for this, or should I use...

6 Dec at 20:50

How do I incrementally serialize and deserialize JSON with ServiceStack?

How do I incrementally serialize and deserialize JSON with ServiceStack? What I have is this: How do I read the fields until I'm at 'object', then serialize the whole 'object' into a .NET type and the...

27 Mar at 09:11

JSON.NET Error Self referencing loop detected for type

JSON.NET Error Self referencing loop detected for type I tried to serialize POCO class that was automatically generated from Entity Data Model .edmx and when I used I got the following error: > Error ...

28 Jan at 21:24

Is polymorphic deserialization possible in System.Text.Json?

Is polymorphic deserialization possible in System.Text.Json? I try to migrate from Newtonsoft.Json to System.Text.Json. I want to deserialize abstract class. Newtonsoft.Json has TypeNameHandling for t...

How to serialize a dynamic object to a JSON string in dotnet core?

How to serialize a dynamic object to a JSON string in dotnet core? I am passing a JSON payload to an API Controller, and one of the fields is dynamic because the field needs to be passed again as a JS...

How to deserialize object derived from Exception class using Json.net?

How to deserialize object derived from Exception class using Json.net? I'm trying to deserialize object derived from Exception class: It gives me error: > ISerial

10 Jun at 05:35

Generate JSON object with NewtonSoft in a single line

Generate JSON object with NewtonSoft in a single line I'm using the JSON library [NewtonSoft](http://nuget.org/packages/newtonsoft.json) to generate a JSON string: Output: My question: Is it possible ...

17 Dec at 15:42

How to deserialize class without calling a constructor?

How to deserialize class without calling a constructor? I'm using Json.NET in my WCF data service. Here's my class (simplified): How can I deserialize that class invoking a constructor using `JsonConv...

19 Dec at 08:10

JSON.NET how to remove nodes

JSON.NET how to remove nodes I have a json like the following: I just want to trans

18 Apr at 13:52

JSON.Net get native type of value

JSON.Net get native type of value Using JSON.Net, how do I get the native type of a value in a JSON file? Namely, I'm after simply if it's a string (value enclosed in quotations) or not.

17 Feb at 15:7