JObject拼接Json字符串

            JArray j = new JArray();
            JObject obj = new JObject(
                    new JProperty("aa", "111")
                    );
            JObject obj2 = new JObject(
                            new JProperty("bb",
                                new JObject(new JProperty("cc", "33"))
                                ));
            obj.Add(obj2);

            JsonObject jsonObject = new JsonObject();
            jsonObject.Put("touser", "openid");
            jsonObject.Put("template_id", "模板id");
            jsonObject.Put("url", "http://www.baidu.com");

            JsonObject data = new JsonObject();
            JsonObject first = new JsonObject();
            first.Put("value", "hello");
            first.Put("color", "#173177");
            JsonObject keyword1 = new JsonObject();
            keyword1.Put("value", "hello");
            keyword1.Put("color", "#173177");
            JsonObject keyword2 = new JsonObject();
            keyword2.Put("value", "hello");
            keyword2.Put("color", "#173177");
            JsonObject keyword3 = new JsonObject();
            keyword3.Put("value", "hello");
            keyword3.Put("color", "#173177");
            JsonObject remark = new JsonObject();
            remark.Put("value", "hello");
            remark.Put("color", "#173177");

            data.Put("first", first);
            data.Put("keyword1", keyword1);
            data.Put("keyword2", keyword2);
            data.Put("keyword3", keyword3);
            data.Put("remark", remark);

            jsonObject.Put("data", data);

            var jsonString = jsonObject.ToString();

 

JObject拼接Json字符串

上一篇:.Net之静态资源


下一篇:ajax