一、JSON的创建
JSON类:JObject、JArray、JValue、JProperty(key/value)、JToken
1、JSON对象的创建
private JObject CreateJSON()
{
JObject pObject = new JObject();
pObject["name"] = this.txtName.Text.Trim();
pObject["addressAll"] = "";
pObject["lon"] = this.txtCoordX.Text.Trim();
pObject["lat"] = this.txtCoordY.Text.Trim();
pObject["geotext"] = "";
pObject["cityCode"] = "360700";
pObject["type_code"] = "030003";
pObject["creator"] = "";
pObject["province_name"] = this.cmbRegion1st.Text.Trim();
pObject["city_name"] = this.cmbRegionSecond.Text.Trim();
pObject["county_name"] = this.txtRegionThird.Text.Trim();
pObject["town_name"] = this.txtRegion4th.Text.Trim();
pObject["lat"] = this.txtCoordY.Text.Trim();
pObject["village"] = this.txtRegion5th.Text.Trim();
pObject["street"] = this.txtAddress.Text.Trim();
pObject["streetNum"] = "";
pObject["street_suffix"] = "";
pObject["community"] = this.txtResidentName.Text.Trim();
pObject["communitySuf"] = this.txtResidentSuffix.Text.Trim();
pObject["buildNum"] = "";
pObject["buildSuf"] = "";
pObject["landmark"] = this.txtLandmark.Text.Trim();
pObject["lm_suffix"] = this.txtLandmarkSuffix.Text.Trim();
return Object;
}
JObject.Parse(string json);
JObject.FromObject(object o);
JObject.Load(JsonReader reader).
2、JSON数值的创建
private JArray CreateJSON()
{
JObject pObject = new JObject();
pObject["name"] = this.txtName.Text.Trim();
JArray jArray = new JArray();
jArray.Add(pObject);
return jArray ;
}