-1
An error occurred while trying to import using System.Runtime.Serialization.Json. How to solve?
The code converts Json to Object and vice versa, I’m only posting a part of it.
using System.Text;
using System.IO;
using System.Runtime.Serialization.Json;
namespace Converte_Object_Json
{
public class JsonConversao
{
public string ConverteObjectParaJSon<T>(T obj)
{
try
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
MemoryStream ms = new MemoryStream();
ser.WriteObject(ms, obj);
string jsonString = Encoding.UTF8.GetString(ms.ToArray());
ms.Close();
return jsonString;
}
catch
{
throw;
}
}
}
}
App information:
Microsoft Visual Studio Community 2019 Version 16.0.4 Visualstudio.16.Release/16.0.4+28803.452 Microsoft . NET Framework Version 4.7.03190
Installed Version: Community
ASP.NET and Web Tools 2019 16.0.12313.64372
ASP.NET Web Frameworks and Tools 2019 16.0.12313.64372
*It’s amazing how most Brazilians are so rotten, no matter how much you dedicate yourself to something will always have a child of the p*** that will negatively answer your question without contributing shit*
Check out this https://stackoverflow.com/questions/22255640/why-cant-i-reference-system-runtime-serialization-json-in-c-sharp
– Victor Carnaval