c# convert object to json
using Newtonsoft.Json;
var jsonString = JsonConvert.SerializeObject(obj);Newtonsoft.Json.JsonConvert.SerializeObject(new {foo = "bar"})var json = new JavaScriptSerializer().Serialize(obj);using System;
using System.Web.Script.Serialization;
public class MyDate
{
public int year;
public int month;
public int day;
}
public class Lad
{
public string firstName;
public string lastName;
public MyDate dateOfBirth;
}
class Program
{
static void Main()
{
var obj = new Lad
{
firstName = "Markoff",
lastName = "Chaney",
dateOfBirth = new MyDate
{
year = 1901,
month = 4,
day = 30
}
};
var json = new JavaScriptSerializer().Serialize(obj);
Console.WriteLine(json);
}
}var jsonString = JsonConvert.SerializeObject(ObjectModel);
Also in JavaScript:
- ajax response length
- lodash map
- js replace text link with anchor tags
- how to know if a number has a decimal number js
- adonis andwhere
- remove duplicate objects from array javascript
- immutable values
- file system replace line js
- factorial javascript
- express get request origin
- variable in js
- how to remove a value from an array and return the new array in javascript
- express error handling
- How do I redirect to another webpage
- d3 tree dag
- jquery extend
- deploy react app netlify
- javascript online test
- javascript string contains
- cypress support ability to set viewport in `before`
- how to compare two strings in javascript if condition
- jQuery Event Methods
- how to loop through all tags in html
- how to assign an rest operator in javascript