[C#] How to deserialize Dictionary from a json-string?

Hello community,
I spent a lot of time to try to deserialize my json data into a Dictionary<string, object>().
Json data is ok, Newtonsoft is well loaded but I always got an exception regarding “system.reflection → system.typeInitialization”

The only other topic I found was this one C# Events, passing a Dictionary object?
So I tried a lot of different type in order to make it works but without any success.

For example, this code will raise the exception.

string s = "{ \"adder\": -1216765807 }";
 IDictionary<string, object> dico = JsonConvert.DeserializeObject<IDictionary<string, object>>(s);

Any idea are welcome :slight_smile:

Are you using the sl5 version of JSON.NET?

I’m currently using Newtonsoft nuget package.
I just tried to install the nuget for Json.NET but it seems I can’t with .NetFramwork V 4.5.2.

by using the ‘sl5’ what do you mean please ?
Is it correct to be in 4.5.2 or did you went to .net standart version ?
Thanks

The solution is to select the specific 12.0.2 nuget package version of Newtonsoft.Json.
Once installed, go in your project folder and then open the “packages” directory.
Here you have to follow this path “packages\Newtonsoft.Json.12.0.2\lib\portable-net40+sl5+win8+wp8+wpa81

findNewtonsoftSL5

This is where is the Newtonsoft.Json.dll that currently works with FiveM. No more “BadImageException” or “Reflection/Type” issues.