Questions tagged [jsonconverter]
111 questions
0
votes
0 answers
Convert string with German culture format to double using JsonConvert
I need to convert German format currency in a JSON (value may be negative or positive) to Double, I am able to do it using double.parse and specifying NumberStyle, something like below
CultureInfo culture =…

nirag tibdewal
- 81
- 1
- 5
0
votes
1 answer
How do I use ParseJson in VBA to get selected items in response?
I am trying to select two values from a JSON response in VBA, using the JsonConverter.bas file from GitHub. I am not sure I am calling the fields correctly. When I run the following code I get the "Run-time error '13': Type mismatch" error message.…

user1781336
- 85
- 4
- 12
0
votes
3 answers
How to write List to Json in scientific notation in c#?
I'm trying to serialize List to json file like this
class ScientificDoubleConverter : JsonConverter
{
public override bool CanRead { get { return true; } }
public override bool CanConvert(Type objectType)
{
return true;
}
public…

Juri
- 1,531
- 2
- 20
- 43
0
votes
0 answers
Custom JsonConverter with nested interfaces
I have a custom JsonConverter which I need for serialization in my controller( [FromBody] ). The problem is that when I have nested interfaces on this property, the serializer is recreated therefore the converter setting is lost.
public class…

green
- 153
- 3
- 13
0
votes
0 answers
How do I get the value of a json property from a JProperty in json.net?
I am working to create a JsonConverter and a ContractResolver that I can use to manage property and type serialization without using NewtonSoft attributes.
p.s., I am surprised these features are not already created somewhere
I've created a Contract…

Jens Bright
- 33
- 1
- 4
0
votes
1 answer
JsonConverter of generic and complex type fails "Additional text found in JSON...."
I am trying to use a json converter without success.
I have a sensor class which can (de)serialize json:
internal class JsonSensor : IJsonSensor where T : struct
{
[JsonProperty(PropertyName = "value")]
public T Value { get; set; }
…

bas
- 13,550
- 20
- 69
- 146
0
votes
1 answer
JsonConvert.DeserializeObject throws an exception when deserializing JSON with a hex value into an sbyte property
I have a machine-generated class MyData which has sbyte members. The actual class is long and not very readable, but here is a fragment of it:
class MyData
{
private sbyte _MuxControl;
public sbyte MuxControl
{
get { return…

user1439579
- 131
- 10
0
votes
0 answers
Apply custom converter based on field name
I have a custom JSON converter for a class that has several fields of various types, I have an specific rules to map negative double fields to null, but I want that rule applied based upon field name, ie:
I have class
public class sampleClass
{
…

Diego Satizabal
- 119
- 1
- 7
0
votes
1 answer
JsonConverter, Error Object Required when key doe not exists
I am using connect VBA with API and sometime the JSON that got returned from the API has dynamic keys for example.
like this
json =[{"oeange":"good",}{"banana":{"color":"yellow"}},{"cat":"grumpy"}]
and sometime like this
json =…

kelle
- 1
- 2
0
votes
1 answer
C# JsonConverter can convert properties depending on the class
I want to write a JsonConverter it can convert a determinate property type but only depending on the class they are defined.
I am registering the JsonConverter globally via Web API:
var config = GlobalConfiguration.Configuration;
var jsonSettings =…

user9923760
- 596
- 2
- 8
- 18
0
votes
1 answer
Json.NET C#: Serialising a collection based on whether or not the collection field has been decorated with a certain attribute
I'm building a serialisation system using Json.NET in Unity. The basic ideas is that classes which need to have their references serialised are decorated with [Ref], like this:
// Wine can be referenced, and these references need to be serialised as…

Thomas Slade
- 129
- 9
0
votes
0 answers
Update value in JObject, in JsonConverter ReadJson
I am trying to update/change a value in a class when I Deserializing a json.
I need to do this in a JsonConverter, but I am getting this error:
Token PropertyName in state Property would result in an invalid JSON object. Path '[0]'.
This is the my…

Don Juan
- 171
- 2
- 17
0
votes
4 answers
Converting json to c# object
I have an api that returns me a json with information about the data transition and an array with data
{
"code": "200",
"result": true,
"message": "",
"data": {
"item": [
{
"id": "5",
…

Emiry Mirella
- 567
- 1
- 7
- 21
-1
votes
1 answer
How to fix JsonConverter's "Unable to parse back Raw Value" error?
I've been successfully writing and parsing back (recursively) my data using a custom JsonConverter, using this:
public override void WriteJson(JsonWriter writer, ManagedSubData value, JsonSerializer serializer)
{
skipOverMe = true;
…

Steven Goulet
- 23
- 4
-1
votes
1 answer
How to get the JsonConverterAttribute to use the same NamingStrategy as the JsonConvert.Deserialize function
I have the following class to serialize
class Container
{
[JsonConverter(typeof(PropertyConverter))]
public PropertyBase SomeProperty { get; set; }
}
Which is serialized with
var settings = new JsonSerializerSettings
{
ContractResolver…

Jay
- 3,373
- 6
- 38
- 55