JSON浅析

一、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 ;
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值