Linked Questions
16 questions linked to/from How can I serialize/deserialize a dictionary with custom keys using Json.Net?
2
votes
0
answers
769
views
Serialize/deserialize a dictionary with hashset<string> as key [duplicate]
Pertinent sections of the class I'm trying to serialize/deserialize:
public class SampleClass
{
[JsonPropertyName("DimensionValueDictionary")]
public Dictionary<string, List<...
0
votes
1
answer
77
views
Getting Collection text while serializing List<string> inside a Dictionary using JsonConvert in C# [duplicate]
So I have the following data structure defined in my program:
Dictionary<string, Dictionary<List<string>, int>> myTopDict = new Dictionary<string, Dictionary<List<string>,...
0
votes
0
answers
39
views
Serialize/Deserialize complex Dictionary<ClassA><ClassB> by Newtonsoft JSON gives me errors while deserializing [duplicate]
My JSON looks like:
[
{
"Key": {
"PatientName": "Hans Gerd",
"Alter": 81,
"Geschlecht": "M",
"...
8
votes
2
answers
8k
views
Serialize Dictionary<,> as array in Json.NET [duplicate]
How can I make Json.NET serializer to serialize IDictionary<,> instance into array of objects with key/value properties?
By default it serializes the value of Key into JSON object's property ...
3
votes
1
answer
24k
views
Remove/Replace newline character from JSON in .Net using JsonConvert
I need to remove some newline characters from some string values while serializing to JSON -- i.e. during c# object to JSON conversion. How can this be done?
public static string ToJson(this object ...
1
vote
3
answers
8k
views
Converting a Dictionary to JSON with JSON.NET
I've a problem converting a dictonairy to JSON.NET. I'm sure i'm missing some points. Also my experience in working with JSON is small and I mostly did it from php not from c#.
It adds &qout i'm ...
3
votes
2
answers
5k
views
newtonsoft json.net - deserializing dictionary with value tuple key
I get an error when deserializing a dictionary with value tuple keys. I think it converts the tuple into a string then is unable to deserialize it back as a key:
Newtonsoft.Json....
1
vote
2
answers
4k
views
Get Tuple from string returned by Tuple.ToString()
Say, we have that code:
var tuple = new Tuple<double, int>(10.6, 2);
var tupleString = tuple.ToString(); //returns "(10.6, 2)";
Can we get a new Tuple instance from tupleString without ...
4
votes
3
answers
3k
views
JsonConvert dictionary with key of type Vector2Int
I am developing a game which has a class called UserInfo.
Inside the UserInfo class there is a public List<Lineup> lineups variable.
And Lineup contains public Dictionary<Vector2Int, ...
3
votes
1
answer
709
views
Detect if it's a Dictionary and the key is assignable from a specific type
I'm working on a custom JsonConverter, and override the CanConvert-method.
public override bool CanConvert(Type objectType)
{
return (typeof(IDictionary).IsAssignableFrom(objectType) ||
...
2
votes
1
answer
1k
views
C# Deserializing a Dictionary<(Enum,Enum),string> with JSON.NET
I've been struggling to deserialize a Dictionary with Enum Tuple keys in Json.Net.
The main problem is that the deserializer can't convert the values back to the specified Enum Tuple whether it's the ...
3
votes
1
answer
615
views
Custom JSON Derivative Format
I would like to have a serialization format that is nearly identical to JSON, except that key-values are represented as <key>="<value>" instead of "<key>":"<value>".
With ...
4
votes
0
answers
591
views
WEB API serialization of Dictionary composite Key
I am using Web API service. My class is as follows
public class MyClass
{
public Dictionary<MyClass, List<MyClass>> MyDataDictionary { get; set; }
public string Id { get; set; }
...
0
votes
0
answers
566
views
Serialize Dictionary with complex key to JSON using JsonConverter
I would like to serialize Dictionary with complex key to JSON by serializing it as a list of KeyValuePair and deserialize it back to dictionary using Json.Net's JsonConverter.
I use this Dictionary ...
1
vote
0
answers
377
views
Try to serialize a nested dictionary of int[] with Json.Net [duplicate]
I'm trying to serialize a nested dictionary of int arrays (<int[], <int[], int>>) with Json.net but when I run it through the serializer:
string dumpFile = JsonConvert.SerializeObject(...