Esempio n. 1
0
 // async method for serializing dotnet objects
 static async void AsyncSerialize(string path, matchingObject obj)
 {
     using (FileStream fs = File.Create(path))
     {
         await JsonSerializer.SerializeAsync(fs, obj);
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // create dotnet object
            matchingObject obj = new matchingObject();

            obj.Id   = Int32.MaxValue;
            obj.Type = "Gold";

            /*  Serialization Process */

            // take dotnet obj and create json
            string jsonString = JsonSerializer.Serialize(obj);

            // sync
            File.WriteAllText("test.json", jsonString);
            // async
            AsyncSerialize("other.json", obj);