PopulateData with NewtonSoft instead of DataContractJsonSerializer

Hello,

I'm trying to use NewtonSoft instead of DataContractJsonSerializer?
Is it not a better solution more simple?

 private static T PopulateData(string fileName)
        {
            var localFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            
            
            var fileText = File.ReadAllText(Path.Combine(localFolder, fileName));
            byte[] byteArray = Encoding.ASCII.GetBytes(fileText);
            

            T obj;
            using (var stream = new MemoryStream(byteArray))
            {
                using (var reader = new StreamReader(stream))
               
                {
                    var json = reader.ReadToEnd();
                    obj = JsonConvert.DeserializeObject(json);
                }
            }

           

            return obj;
        }

1 Reply 1 reply marked as answer

SS SaiGanesh Sakthivel Syncfusion Team September 7, 2020 12:09 PM UTC

Hi Mihaela,  
  
Thank you for contacting syncfusion support.  
  
We have checked the reported query “PopulateData with NewtonSoft instead of DataContractJsonSerializer” from our end. We would like to inform you that you can retrieve data from json file using DeserializeObject method.  
  
You can install the Newtonsoft.Json package to the application to deserialize the json data. Please refer the following documentation regarding the same,   
  
We hope this helps. Please let us know if you need further assistance. 
  
Regards,  
SaiGanesh Sakthivel

Marked as answer
Loader.
Up arrow icon