I'm trying to serialize a json string into an object. I'm forced to use .net version 4.6.2 so I can't use the tools I would normally use. I can't either user async because of the framework I'm working in.
I have come up with this method and it's supposed to serialize the json string into the object using Newtonsoft.Json:
private static void Serialize(object obj, string json)
{
var serializer = new JsonSerializer();
using (var sw = new StreamWriter(json))
using (JsonWriter writer = new JsonTextWriter(sw))
{
serializer.Serialize(writer, obj);
}
}
I have this exception:
System.IO.PathTooLongException: 'The path '{...}' is too long, or a component of the specified path is too long.'
The json holds 10.000 products so it's going to be long.
How can this be overcome?
Adding:
<?xml version="1.0" encoding="utf-8" ?>
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false" />
</runtime>
to App.config doesn't change anything.