All Questions
7,342
questions
-2
votes
1
answer
49
views
C# JSON: I want to deserialize an empty string to a custom type. But it seems to be always defaulting to null. Is there a way to achieve this
I want JsonConvert.DeserializeObject<CustomType>("") to be deserialized to new CustomType()
but this is always deserialized to null.
this is using Newtonsoft json, have tried using a ...
1
vote
1
answer
90
views
Json.Net How to Serialize and Deserialize custom types in custom way
I use the R3 reactive programming library and Newtonsoft. I'm trying to save object data to a file so that I can later read from it. The recording just works without problems. But when reading the ...
0
votes
1
answer
33
views
Read json dictionary with multiple sub keys into unity c# script
I am trying to get my data from a json file into unity with a c# script. The goal is to move all players at the same time based on positional data, which i already have. I need to group the ...
0
votes
1
answer
48
views
cannot convert from 'string' to 'Newtonsoft.Json.JsonReader'CS1503 error showing up how to i convert to newtonsoft.Json.JsonReader?
I was trying to retrive information from a json file and save it to mapCollision and layers
but CS1503 error showing up
the json file includes 2 jagged arrays which represent a map
{
"layer&...
1
vote
1
answer
84
views
C# Newtonsoft JSON Deserialization: Empty list value represented as "{}" instead of "[]", throws exception
We are currently supporting an API integration with a 3rd party that transmits responses via JSON. We are using C# .NET and Newtonsoft JSON (version 13.0.1) to handle serialization of requests and ...
0
votes
1
answer
49
views
Dynamically set the Property name to be the name of the Type(typeof(T).Name)
var appsettings = JsonConvert.DeserializeObject<AppSettings<PersonModel>>(configData);
class AppSettings<T>
{
[JsonProperty(PropertyName = typeof(T).Name)]
public T ...
0
votes
0
answers
67
views
In C#, why does System.Text.Json.JsonSerializer.Serialize fail to serialize correctly when using dependency injection (interfaces)? [duplicate]
Why does the following write out only "{}"?
var myLogin = new TestLogin
{
UserName = "[email protected]",
Password = "Pass123"
};
Console.WriteLine(System.Text.Json....
1
vote
2
answers
88
views
Filtering using Newtonsoft with multiple conditions in C#
I'm trying to extract values from json using Newtonsoft, but I'm having some problems.
Below is the json snippet I use:
{
"result": {
"areas": [
{
...
0
votes
2
answers
91
views
Parse only some attributes of a JSON file in c# using the Newtonsoft Json.NET library
Good day,
I am new to JSON handling and have encountered an issue I can't resolve, despite checking the Newtonsoft documentation. I hope you can help me out.
I have a JSON file downloaded locally (@&...
0
votes
1
answer
53
views
Treating {} as null when deserializing json objects using custom JsonConverter
Note: re: related questions - they have similar titles but their titles are misleading: reading them reveals they're about a different situation, they're worried about INCOMING null, whereas I need a ...
-2
votes
1
answer
76
views
Deserialize JSON(not in an array) with C# and write to a SQL table [duplicate]
Would like some help in parsing the JSON and insert (or at least output the key value pairs) without a specific class/object.
JSON string (portion):
{
"message": "Success",
"...
1
vote
0
answers
31
views
Json object deserialization problem - property can have nested json object, but the serializer throws an exception [duplicate]
(.NET Framework 4.7.2) I am querying data from a web API and using the Newtonsoft JSON package for deserialization. The API returns an array of time/value pairs. My code works when the 'value' is ...
2
votes
1
answer
147
views
.NET Serializing a complex Dto to JSON string
I am working with a Dto Structure that looks like the following. I will omit information regarding other derived types as they are not part of the problem at hand. Take note that the OldValue and ...
0
votes
2
answers
173
views
Reading Json number as a string
What I need:
Deserialize Json string to and object
Do some stuff
return it as a string at the end
What is the problem?
When Json has property like {"foobar" : 0.0000000000000000001}, it is ...
-1
votes
1
answer
65
views
Is it posible to deserialize JSON to a generics object in C# and have the property name be dynamic?
Updated: Either of the two comments at time of update or the accepted answer are functional solutions, however at the scale being applied introduce more risk and complexity than they would save. ...