Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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

# write json file

# write json file
import json
d = {
    "firstName": "Tom",
    "lastName": "Jack",
    "gender": "male",
    "age": 35,
    "address": {
        "streetAddress": "126",
        "city": "San Jone",
        "state": "CA",
        "postalCode": "95150"
    },
    "phoneNumbers": [
        { "type": "home", "number": "4083627627" }
    ]
}

filename = "/content/sample_data/sample1.json"
with open(filename, 'w') as f:
  json.dump(d, f)
  
Comment

PREVIOUS NEXT
Code Example
Python :: python join dict 
Python :: Django populate form from database 
Python :: remove duplicates from tuple python 
Python :: hash() python 
Python :: How to get the first and last values from the dataframe column using a function 
Python :: python random walk 
Python :: socket exception python 
Python :: how to know if a key is in a dictionary python 
Python :: selenium chrome options suppress warnings python 
Python :: remove first item form dictionary python 
Python :: UnicodeDecodeError: ‘utf8’ codec can’t decode byte 
Python :: print for loop in same line python 
Python :: read dict from text 
Python :: list -1 python 
Python :: -- python 
Python :: __str__ method python 
Python :: python define class 
Python :: python unresolved import vscode 
Python :: print whole list python 
Python :: unique value python 
Python :: find max length of list of list python 
Python :: Iterate through string backwards in python 
Python :: django get latest object 
Python :: Matplotlib inside Jupyter | Jupyter generate graphs. 
Python :: download pytz python 
Python :: copy a dictionary python 
Python :: one liner if else replacement in python 
Python :: how to convert pandas series to 2d numpy array 
Python :: double variable for loop python 
Python :: pandas do not display index 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =