Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

c# write to file in json

//if you want to use a list and add it to a file in json do this
using System.IO;
using System.Text.Json;

List<Data> data = new List<Data>();
  public void SaveData()
        {
            using (StreamWriter sw = File.CreateText("data.json"))
            {
                sw.Write(JsonSerializer.Serialize(data));
            }
        }
Comment

c# write json to file

using System.Text.Json;
using System.Text.Json.Serialization;

List<data> _data = new List<data>();
_data.Add(new data()
{
    Id = 1,
    SSN = 2,
    Message = "A Message"
});

using FileStream fileStream = File.Create(@"D:path.json");
await JsonSerializer.SerializeAsync(createStream, _data);
Comment

Write JSON file C#

using System.Text.Json;
using System.Text.Json.Serialization;

List<data> _data = new List<data>();
_data.Add(new data()
{
    Id = 1,
    SSN = 2,
    Message = "A Message"
});

string json = JsonSerializer.Serialize(_data);
File.WriteAllText(@"D:path.json", json);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery cdn google 
Javascript :: react leaflet marker onclick 
Javascript :: set html attribute jquery 
Javascript :: reactdom.render is no longer supported in react 18 
Javascript :: speed facebook video 
Javascript :: array chunk javascript 
Javascript :: javascript date get current date 
Javascript :: how to check if iframe is loaded 
Javascript :: add keyup event javascript 
Javascript :: javascrip for each element of class 
Javascript :: efault loader is not compatible with `next export`. 
Javascript :: how long old upvc 
Javascript :: how to kill a running node process 
Javascript :: js regex between two words 
Javascript :: set focus javascript 
Javascript :: model schema mongoose 
Javascript :: javascript change data attribute value 
Javascript :: js trigger change event 
Javascript :: how to make background image move mmousemove jquery 
Javascript :: how to clear innerhtml in javascript 
Javascript :: scroll to bottom of an element react 
Javascript :: ngcc failed angular 9 
Javascript :: js alert yes no 
Javascript :: sleep javascript 
Javascript :: js last element of array 
Javascript :: digitalocean app platform node version 
Javascript :: js push param to url 
Javascript :: jquery confirm delete massege 
Javascript :: refresh div jquery 
Javascript :: how to make sure footer is fixed at bottom of page 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =