JavaScript объект на json String
var person={"first_name":"Tony","last_name":"Hawk","age":31};
var personJSONString=JSON.stringify(person);
Grepper
var person={"first_name":"Tony","last_name":"Hawk","age":31};
var personJSONString=JSON.stringify(person);
var sample = {
name: "Himansu Jangid",
github: "https://github.com/himanshurajora",
age: 19
}
var converted = JSON.stringify(sample);
// now the converted variable contains stringified json object in the single line
// ------------
// to keep the json structure
converted = JSON.stringify(sample, null, '\t');
// now the object will be stringified but the structure will remain same
// output - '{\n\t"name": "Himansu Jangid",\n\t"github": "https://github.com/himanshurajora",\n\t"age": 19\n}'
JSONObject json = new JSONObject();
json.toString();
var oTemp = JSON.parse(buf.toString());
JSON.stringify()
List<userdetails> details = new List<userdetails>();
userdetails user = new userdetails();
details.Add(new userdetails { userid = 1, username = "suresh", location = "chennai" });
string strserialize = JsonConvert.SerializeObject(details);