Questions tagged [jsonconverter]
111 questions
1
vote
1 answer
How to deserialize an item into different types? (Newtonsoft, C#, .NET)
I'm getting a json message with a field called "item" that can be deserialized as class foo or class bar.
How do I implement this in C#?
I assume something like this:
public class FooOrBar
{
// Only one of the two will get populated.
…

Shay Ohayon
- 161
- 2
- 12
1
vote
1 answer
Why is my object not filled up aspdotnet json converters
I have a simple http server. I send some json object over POST
At first, I use json converter to parse the json and fill nonserializable objects up
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,…

cartuhokni
- 11
- 1
1
vote
2 answers
Write List to Json array without indentation using System.Text.Json
NB: I am using System.Text.Json not JSON.NET for which there is similar question that has been answered. I need the same answer but for System.Text.Json. I would like to write my class to Json and ensure that it is human readable. To do this I…

Tim Rutter
- 4,549
- 3
- 23
- 47
1
vote
3 answers
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3 path $[0] Gson Error
The error occurs whenever i request for @Post method. @Get method will work fine. well the response coming fine in PostMan too. Can someone help me why it is happening.
Headers used are
header("Content-Type", "application/json")
header("Accept",…

Emulator
- 45
- 10
1
vote
0 answers
StackOverflowException when deserializing a hierarchy of immutable polymorphic types with Newtonsoft JSON
I have a hierarchy of polymorphic immutable classes that I would like to serialize to and deserialize from JSON using Newtonsoft JSON.
Here's a simplified set of example classes:
[JsonConverter(typeof(ItemJsonConveter))]
public abstract class…

Eric Anastas
- 21,675
- 38
- 142
- 236
1
vote
2 answers
Convert JSON to XML and again convert in JSON
I have below format JSON file which is having different type of values (string, number, boolean and Null). I want to convert this JSON in xml format for some data processing and after that I want to convert back in same JSON format. Needs to insure…

user2478625
- 123
- 2
- 12
0
votes
2 answers
Converting Json in flutter
I am trying to convert my data from Json to a Map but I am getting this error that says type 'List' is not a subtype of type 'String'. I am actually returning a list of route as contained in the server.I had did something similar to this by…

Ukeme Elijah
- 157
- 3
- 13
0
votes
1 answer
JsonConvert.DeserializeObject - Current JsonReader item is not an object: StartArray
I am trying to map the JSON nodes to my class using path and get an error when DeserializeObject. Error is thrown at JObject.Load(reader).
'Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1,…

user1263981
- 2,953
- 8
- 57
- 98
0
votes
0 answers
VBA, JSONConverter from Github, Trouble with multiple levels of json data
Afternoon All,
I'm using the VBA-TOOLS > JSONConverter from GITHUB. I have it working for the first "layer" or "level" of my JSON string but I cannot get it to drop down a level.
If you look at my example code, the first "level", fields…

Steven
- 1
0
votes
2 answers
Deserialize json with dynamic number of objects and keys
I have a json string that I need to deserialize (in a WPF app, using System.Net.Json). A subobject (node) in the tree contains a variable number of propertiers/nodes with variable names.
A "minimal" sample looks like this:
"intervals":…

Erik Thysell
- 1,160
- 1
- 14
- 31
0
votes
1 answer
Deserializing JSON with UTC/Zulu Time String using System.Text.Json
I am having some issues deserializing JSON that has a Zulu formatted time string. I continue to receive an exception that states the string is not a data and time.
I have the following string being returned from and REST service.
{
".issued":…

Ducky
- 11
- 2
0
votes
0 answers
Userform not displaying in VBA
I have this code that gets the distance between two places. It should open a Userform so I can choose between the 3 different routes but the Userform is never displayed and the value of the cell I call the function from just displays #VALUE!.
Does…
0
votes
1 answer
Excel VBA-JSON: How do loop through an array inside a JSON object?
Consider this JSON object:
{
"fileName": "Batch_01032023_SakerItemData.xlsx",
"fileLocation": "C:\\Temp",
"message": "There are 3 errors. Please correct and try again.",
"error": [
"{Item} failed validation:Item is required.:8",
"{Type}…

PEBKAC
- 3
- 4
0
votes
0 answers
How to put condition on Custom Json Convertor
I have defined a custom Json Convertor for my DTO as below
public class CustomJsonConverter : JsonConverter where T : class
{
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
…

user16963532
- 1
- 1
0
votes
2 answers
Custom JSON.Net JSON Converter with nested objects
Sourcecode to showcase the issue: https://github.com/Snuffsis/ConverterExample
So I have an issue that is exactly the same as in this stackoverflow question:
C# Newtonsoft.Json Custom Deserializer
And while that answer does help for properties that…

Snuffsis
- 21
- 5