Questions tagged [jsonconverter]
111 questions
0
votes
1 answer
Book: Flutter Apprentice - Try to make a generic ModelConverter from a Api Response
In the excellent Flutter book by Raywenderlich, Chapter 13 is dedicated to obtaining Responses from an api using libraries Chopper and JsonConverter.
The code in Github is here
He also proposes the use of a response wrapper like functional…

Santi
- 491
- 6
- 14
0
votes
1 answer
Newtonsoft JsonConvert DeserializeObject cannot ignore Default Value from entity err?
Here is the Sample code:
I have a TargetEntity which contains a bool list, by default, it is set to a seven elements list of true value.
What I am trying to do is deserialize from JSON, which contains a list of seven false value.
However, when…

Yatong
- 3
- 3
0
votes
0 answers
Using JsonConverter on a property that is sometimes missing, as well as checking for single item or array
In the Json deserialization model, I have a class member that can be a single item or an array, thus I use a JsonConverter to deal with it.
However, sometimes the entire property is missing in the response as well. The model has a property that the…

ProgrammerBret
- 137
- 2
- 12
0
votes
1 answer
How does one map an array with indices to an object with a custom JsonConverter
I've seen a couple questions regarding what I'm trying to do, however they seem to be using JSON.Net which is something I don't want to use as .NET Core / .NET 5 has a JsonSerializer built in.
I'm calling an API for HTTP RPC for RuTorrent that…

Owen
- 76
- 10
0
votes
2 answers
NewtonSoft JSON not raising Exception when using MissingMemberHandling.Error
We use the Newtonsoft Json converter to deserialise API requests. As we don't want to receive data/members which are not part of the request class in the BackEnd, we set SerializerSettings.MissingMemberHandling to…

R. Hoek
- 916
- 8
- 27
0
votes
0 answers
How to use the NewtonSoft JsonConverterAttribute and JToken.FromObject() without calling the JsonConverter recursively
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() and JsonConvert.DeserializeObject()
added a…

Louis Somers
- 2,560
- 3
- 27
- 57
0
votes
1 answer
JSON value not converted to System.Boolean in cURL
I created Boolean converter expecting it would be used automatically on the property IsComplete, but get an error in cURL. What am I doing wrong?
Error
$ curl -k -X PUT -H "Content-Type: application/json" -d "{\"name\": \"momo\",…

momo
- 2,723
- 2
- 11
- 10
0
votes
1 answer
Newtonsoft.Json C# CustomJsonConverter - to replace double seperator as per the culture passed
All, trying to create a custom JsonConverter that changes the decimal seperator based on the culture passed as a parameter while serializing to a Json(similar to this).
Sample Console Application:
using System;
using Newtonsoft.Json;
using…

SriramN
- 432
- 5
- 19
0
votes
1 answer
Where is JsonReader.ReadRawValue?
I am implementing a custom JsonConverter.
In the implementation of WriteJson I use the function JsonWriter.WriteRawValue() to write an object my way.
In the implementation of ReadJson, I want to read and manage the same value my way and I expected…

Ernest Morariu
- 9
- 1
0
votes
1 answer
Catch exception thrown from Custom JsonConverter
I am looking for a way to catch an exception thrown from a custome Newtonsoft's JsonConverter.
I created the following custom converter. JsonConverter attribute in Config class uses it. Config class is used to post a config object and used for Web…

Koji
- 509
- 7
- 21
0
votes
1 answer
Custom JsonConverter (System.Text.Json) producing invalid json
This is the class I want to custom serialize:
public class MyClass
{
public string Key {get; set;}
public IEnumerable Value {get; set;}
}
If I've got a list of it, normal serialization would produce the following output:
[
{
…

UNeverNo
- 549
- 3
- 8
- 29
0
votes
0 answers
Custom JsonConverter not getting called during deserialisation
I'm using AspNet Core 3.1. I implemented a custom Json converter for NewtonSoft Json as below:
public class CustomConverter : Newtonsoft.Json.JsonConverter
{
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer…

kovac
- 4,945
- 9
- 47
- 90
0
votes
1 answer
How can I capture included property names in a JSON web api request with asp.net core?
I am building an asp.net core web api and I need to keep track of properties that were actually included in a JSON body, since .NET doesnt have the concept of undefined as in javascript, just null.
I created an interface which all of my models…

Zach
- 1,311
- 3
- 16
- 36
0
votes
2 answers
Problem with DeserializeObject Json String
I get the following json string format from an API:
{
"Items":[
{
"Item":{
"Codes":{},
"Date":1523539700000,
"Name":"Item1",
"Price":"15"
}
},
{
…

johnslippers
- 81
- 1
- 16
0
votes
1 answer
JsonConvert.DeserializeObject<> is returning null last childtoken of the two childrentokens
I am sending a JObject from the frontend to my API, which is divided into First and Last childtokens, as seen in the picture below:
However, when I am trying to use the following code, the last part of childrendtoken is becoming null
var RVoucher =…

Mutasim Malik
- 61
- 1
- 8