Questions tagged [jsonconverter]
111 questions
1
vote
1 answer
Adding parameter to Json converter during deserialization with converter defined for property
I would like to pass a parameter to the Json converter at the time of deserialization. At the same time, I would like the converter to execute only for the properties indicated by the attribute.
public class Contract
{
…

marcin_
- 41
- 5
1
vote
0 answers
XML to JSON Array Conversion using XSLT
I have a scenario where in I am trying to convert the following XML:
1023
1542
30
Mr
…

megrao1811
- 21
- 2
1
vote
1 answer
Unit test for custom JsonConverter
In my application, I need some parts of the application where I need to have EscapeHtml to escape special characters in string, but not global.
I created a custom JsonConverter class:
using Newtonsoft.Json;
using System;
using…

Sasa Jovanovic
- 324
- 2
- 14
1
vote
0 answers
Catching a Json Serialization Exception (JsonSerializationException)
When deserializing a Json File into an object using the NewtonSoft.Json converter, I see a lot of exceptions written to the console's output. The error is the following one (repeated many times over):
Exception thrown:…

stackMeUp
- 161
- 7
1
vote
1 answer
Migrate Newtonsoft JsonConverter to JsonConverter
I have the following interface
public interface IApiResult : IApiResult
{
TResult Result { get; set; }
}
with a concrete class like this
public class ApiResult : ApiResult, IApiResult
{
public ApiResult( TResult…

Lorenzo
- 29,081
- 49
- 125
- 222
1
vote
1 answer
JSON.Net - How to deserialize a nested field of a custom type
I've been having trouble finding a question about my particular case:
I need to deserialize the following JSON:
{
"name": "My Farm",
"barns": [
{
"name"": "Barn A"",
"animalTypes": [
"Cow",
…

user3154397
- 33
- 4
1
vote
1 answer
Why is JsonConverter attribute not inherited from interface?
In have the following code:
interface ITyped where TypeEnum : Enum, struct
{
[JsonConverter(typeof(JsonStringEnumConverter))]
public TypeEnum Type { get; }
}
class Foo : ITyped
{
public Foo(FooType type) { Type =…

Kjara
- 2,504
- 15
- 42
1
vote
0 answers
How to reset an Utf8JsonReader to its starting position?
I know from the docs that this is technically not possible (Utf8JsonReader is forward-only with no caching mechanism), but I want to know if I can achieve something equivalent in behaviour.
Below is my use case and the problem I have with…

Kjara
- 2,504
- 15
- 42
1
vote
0 answers
Ignoring the @JsonIgnoreProperties check
There is a class annotated with @JsonIgnoreProperties (base class) and some subclasses extending it.
Now, in one Post API, the request body (a map) could be type of any of the subclasses. I have written code to create instance of base class based on…

N.Rajal
- 105
- 2
- 17
1
vote
0 answers
dictionary with custom keys and values in Json.NET
I have a dictionary which uses classes for the keys and values. For those classes, I created JsonConverters to serialize/deserialize them in a specific way. To serialize the dictionary correctly, I used the following JsonConverter I found at…

Vic
- 55
- 7
1
vote
1 answer
Need Jolt Spec to convert matrix json to denormalized json formart
Can anyone please help me a JOLT spec to convert my matrix type json to denormalized json. Please find the below my input json and my expected josn output.
Input Json:
[
{
"attributes": [
{
"name": "brand",
"value":…

karthi asokan
- 13
- 3
1
vote
1 answer
Deserialize a string field into a property object
Let's say I have an object of type MyClass that is serialized to Json as follows:
{"DurationField":"3 Months", *OtherProperties*}
I want to deserialize this Json into the following class:
public class MyClass{
*OTHER PROPERTIES*
public…

szan
- 11
- 2
1
vote
1 answer
Deserialize complex polymorphic types with System.Text.Json
The dotnet example in the documentation:
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-converters-how-to#support-polymorphic-deserialization
shows manually parsing each property of a polymorphic type. However:
my…

daw
- 1,959
- 1
- 20
- 25
1
vote
1 answer
Parsing JSON in Excel VBA and access array by key
I'm trying to scrape the content from a website (Link) using Excel VBA. Here is the .json response from the server (Link):
{
"TopicDetails": {
"type": 0,
"ccm2Id": 31088568,
"cftId": 0,
"identifier": "FETOPEN-01-2018-2019-2020",
…

Maksim
- 15
- 4
1
vote
1 answer
Asp.Net Core custom converter appsettings JSON for IDictionary
I would like to read appsettings file, but I have problem when one property is defined as IDictionary: the values are converted as string.
For example I have in appsettings defined:
"Queue":{
"Name": "Test1",
"Durable":…

Ozzy
- 304
- 3
- 15