Questions tagged [jsonconverter]
The jsonconverter tag has no usage guidance.
112
questions
0
votes
0
answers
45
views
Windows Defender showing Trojan virus in my own created XLSM file
I'm getting notifications from Windows Defender on my laptop (HP, Windows 10) that the file i myself created, has Trojan:Win32/Leonem & Trojan:O97M/Sadoca.C!ml viruses. Here's a screenshot of the ...
1
vote
1
answer
59
views
InvalidCastException in custom JsonConverter
I am attempting to create a null safe json converter that handles json string values like "null" and return a default instance of a type.
So far it's been working as expected, but I'm ...
0
votes
2
answers
62
views
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 ...
1
vote
0
answers
186
views
Custom System.Text.Json Converter string not working
I wrote a string custom System.Text.Json converter
public class TranslatableJsonConverter : JsonConverter<string>
{
private readonly IHttpContextAccessor _httpContextAccessor;
public ...
0
votes
1
answer
47
views
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 ...
1
vote
1
answer
43
views
How do I run a converter within another converter to handle multi-format content in a complex JSON file in C#?
I am trying to deserialize a JSON file with a complex structure in C#, but I'm facing difficulties due to multi-format content within arrays. Unfortunately, I cannot change the JSON format. Here's an ...
0
votes
0
answers
58
views
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 ...
-1
votes
1
answer
79
views
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 ...
-1
votes
1
answer
93
views
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 = ...
0
votes
2
answers
122
views
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 "...
0
votes
1
answer
346
views
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 ...
0
votes
0
answers
24
views
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 ...
1
vote
1
answer
674
views
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.
...
0
votes
1
answer
78
views
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 ...
1
vote
0
answers
101
views
XML to JSON Array Conversion using XSLT
I have a scenario where in I am trying to convert the following XML:
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<ClientId>1023</ClientId>
<...
0
votes
0
answers
204
views
How to put condition on Custom Json Convertor
I have defined a custom Json Convertor for my DTO as below
public class CustomJsonConverter<T> : JsonConverter<T> where T : class
{
public override T Read(ref Utf8JsonReader ...
0
votes
2
answers
2k
views
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 ...
1
vote
1
answer
374
views
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....
0
votes
0
answers
8
views
Json, how to remove numeric object keys and convert to array instead (JsonConverter)?
I'm calling a webservice, that can take multiple id's as inputs
/getItems?ids=1,2
And it returns this information (i have no control over the results)
{
"status": {
"...
1
vote
0
answers
637
views
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):
...
0
votes
0
answers
358
views
Using JsonConverter with Single Object and a List of Object
I am trying to implement a JsonConverter that will work when deserializing a single object as well as when that object is in a list. It works fine when using with a single object but not when the Json ...
0
votes
0
answers
681
views
The JSON value could not be converted to model in .NET Core
I have these model classes:
public class TransactionInfo
{
public int request_id { get; set; }
public DateTime request_date { get; set; }
public double request_amount { get; ...
0
votes
1
answer
160
views
Outofmemory exception while converting json to list using Gson
I got outofmemory exception while converting json file to list using Gson
Caused by
java.lang.OutOfMemoryError
Failed to allocate a 18874376 byte
allocation with 18575992 free
bytes and 17MB until ...
1
vote
1
answer
158
views
Migrate Newtonsoft JsonConverter to JsonConverter<T>
I have the following interface
public interface IApiResult<TResult> : IApiResult
{
TResult Result { get; set; }
}
with a concrete class like this
public class ApiResult<TResult> : ...
3
votes
2
answers
212
views
Serialize a list of Objects of different Classes (implementing a common Interface) rendering only the Interface Properties (as IActionResult)
I wrote a Controller Action that needs to return a Json with a List of Sports. This Json Array only needs to contain the common properties (defined at the Interface level).
The Interface definition is:...
0
votes
0
answers
189
views
How to deserialize immutable types from standard library using System.Text.Json?
I am trying to serialize and deserialize System.Diagnostics.ActivityContext struct.
According to documentation How to use immutable types and non-public accessors with System.Text.Json I need to add [...
2
votes
1
answer
473
views
Newtonsoft custom converter, string array as parameter [duplicate]
I am trying to create custom json converter ,which can parse date using specified formats
public class MultiFormatDateConverter: JsonConverter {
public override bool CanWrite => true;
...
0
votes
1
answer
194
views
Abp Framework global json converter cannot be configure
I would like to define custom json converter and replace with AbpStringToEnumConverter in abp framework. I am trying to change JsonSerializerOptions.Converters with below code but it's not working.
...
0
votes
0
answers
263
views
Cannot serialize abstract list with Autorest generated client
I've trying to call my controller in a behavior test. It works manually with Postman but not with a generated Autorest HttpClient. I've already created a specific JsonConverter in order to handle ...
2
votes
2
answers
2k
views
System.Text.Json JsonConverter String array to single string
I would like to convert the following JSON. As you can see, the array has a single entry. I would like to convert it into a simple string.
{
"@timestamp": [
"2022-05-24T01:...
1
vote
1
answer
161
views
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": [
{
...
0
votes
1
answer
800
views
Using Newtonsoft JsonConverter to Encrypt JSON object
I'm developing a project that will require me to include credentials for things like an SMTP server. I'd like to store this information along with the complete details of the endpoint in an embedded ...
1
vote
1
answer
272
views
Why is JsonConverter attribute not inherited from interface?
In have the following code:
interface ITyped<TypeEnum> where TypeEnum : Enum, struct
{
[JsonConverter(typeof(JsonStringEnumConverter))]
public TypeEnum Type { get; }
}
class Foo : ...
0
votes
0
answers
275
views
Implementing A Custom JSONConverter To Read/Save Data To A Separate File
I'm working on creating a JSON configuration file setup for my application. The application will require access to sensitive information (specifically login credentials and decryption passwords) ...
-1
votes
1
answer
523
views
polymorphic Json deserialization in nested scenario
I have some classes that I want to (de-)serialize:
public class Top
{
public Top(Sub content) { Content = content; }
public Sub Content { get; init; }
}
public class Sub
{
public Sub(Sub?...
1
vote
0
answers
2k
views
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 ...
0
votes
1
answer
536
views
how to Parse multi level json with vba?
how would I parse this Json String?
'{
' "territory": {
' "RSC": {
' "sector": 1,
' "size": ...
0
votes
1
answer
838
views
Azure Function Json Serialization issue
I'm having issues with my custom serializer sometimes not working when passing information between Orchestration Functions and I don't know if this is because of how the object is nested / constructed ...
3
votes
0
answers
760
views
Custom JsonConverter never gets called by the MVC model binder/controller
I have a custom type that I want the MVC model binder serialize/deserialize using my custom JsonConverter for System.Text.Json. Here is my implementation:
public class Enumeration
{
private ...
2
votes
1
answer
982
views
Resolve cycle references of complex type during JSON serialization using System.Text.Json.Serialization.JsonConverter
There is a complex type with a reference to the object of the same type (sometimes to the same object):
public class User
{
public string Name { get; set; }
public int Age { get; set; }
...
1
vote
0
answers
40
views
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 ...
0
votes
0
answers
63
views
Is it allowed to change some settings from the JsonSerializer in a custom JsonConverter?
When creating a custom JsonConverter and overriding the public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) is it valid to change some settings from that ...
1
vote
0
answers
272
views
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 ...
0
votes
1
answer
592
views
Refit Not Using Configured JsonConverter
I'm using Refit for making HTTP calls and it works as expected for request that expects straight-forward JSON structure. We've requirement now wherein the JSON request needs to be represented little ...
2
votes
2
answers
705
views
Which approach to use for model binding a custom type
My API controller has an endpoint that looks like this:
public async Task<IActionResult> Update([FromBody] UpdateCommand command) { /* ... */ }
That command looks like this:
public class ...
0
votes
0
answers
632
views
Do I need a separate custom JsonConverter for an object and an array of that object? [duplicate]
I'm importing Json from a file. Let's say it looks like this
{
"name": "Test System",
"devices": [
{
"type": "Touchpanel",...
0
votes
0
answers
458
views
c# JsonConverter deserialize Json containing Polymorphic Object [duplicate]
I can't figure out what I am doing wrong. I am trying to deserialize a JSON that has a polymorphic object. Here is my basic classes and set up
public class Information
{
[JsonConverter(typeOf(...
0
votes
1
answer
601
views
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 ...
2
votes
0
answers
687
views
ASP.NET Core 5 doesn't respect neither JsonConverter nor TypeConverter
The title is pretty self explanatory. ASP.NET Core 5 doesn't respect neither the JsonConverter nor the TypeConverter.
The symbols e.g. "TRX/USDT" should be split by / and converted to new ...
5
votes
2
answers
2k
views
Writing a custom converter for appsettings.json
I want to create an appsettings.json converter which converts Symbols to IReadOnlyCollection<Symbol>. The converter should split the string by /, which will result into a BaseAsset/QuoteAsset. ...