c# json from file to object
// read file into a string and deserialize JSON to a type
Movie movie1 = JsonConvert.DeserializeObject<Movie>(File.ReadAllText(@"c:\movie.json"));
// deserialize JSON directly from a file
using (StreamReader file = File.OpenText(@"c:\movie.json"))
{
JsonSerializer serializer = new JsonSerializer();
Movie movie2 = (Movie)serializer.Deserialize(file, typeof(Movie));
}public class Movie
{
public string Name { get; set; }
public int Year { get; set; }
}
// read file into a string and deserialize JSON to a type
Movie movie1 = JsonConvert.DeserializeObject<Movie>(File.ReadAllText(@"c:\movie.json"));
// deserialize JSON directly from a file
using (StreamReader file = File.OpenText(@"c:\movie.json"))
{
JsonSerializer serializer = new JsonSerializer();
Movie movie2 = (Movie)serializer.Deserialize(file, typeof(Movie));
}
string name = movie2.Name;
int year = movie2.Year
Also in JavaScript:
- angular component lifecycle hooks
- js array to string
- date().toisostring().slice(0 10) giving wrong result
- javascript perimeter
- minimize and maximize div in html
- username validation js
- settimeout arrow function javascript
- what is linter javascript
- validatorjs get all errors
- javascript sort
- javascript change page title
- varoables in js
- install nodejs ubuntu 19.04
- laravel open json file in storage
- how to get the value of textarea in react
- javascript submit a form with id
- object json parse nestjs
- import jquery into js file
- palindrome
- check if js property exists in class
- discord javascript how to create a role
- fade in onscroll jquery
- empty array javascript
- how to clear radio field in jquery