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 :: check scroll top height in react js 
Javascript :: how to make view dotted line in jsx 
Javascript :: loop in react depending on number 
Javascript :: javascript sort array smallest to largest 
Javascript :: node js variables in string 
Javascript :: prevent a page from refreshing in react 
Javascript :: Arrays Comparison 
Javascript :: javascript random integer 
Javascript :: how to go back to previous page after updating data in jquery 
Javascript :: remove list content js 
Javascript :: get select2 selected value jquery 
Javascript :: Remove duplicate items form array using reduce() method. 
Javascript :: getx arguments 
Javascript :: placeholder value js 
Javascript :: uncaught evalerror: refused to evaluate a string as javascript because 
Javascript :: how to make proptypes either or 
Javascript :: nodejs date difference 
Javascript :: how many days old am i 
Javascript :: is material ui not working with react 18 
Javascript :: mongoose findbyidandupdate return updated 
Javascript :: how to find network there is no network react native 
Javascript :: javascript style onclick 
Javascript :: push characters to a string javascript 
Javascript :: js map add property 
Javascript :: validate phone number regex 
Javascript :: copy to clipboard jquery javascript 
Javascript :: generate random id javascript 
Javascript :: remove duplicates from array 
Javascript :: difference between .touched & .dirty in angular 
Javascript :: js loop through array backwards with foreach 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =