当前位置: 首页>>代码示例>>C#>>正文


C# JsonTextWriter.WritePropertyName方法代码示例

本文整理汇总了C#中Newtonsoft.Json.JsonTextWriter.WritePropertyName方法的典型用法代码示例。如果您正苦于以下问题:C# JsonTextWriter.WritePropertyName方法的具体用法?C# JsonTextWriter.WritePropertyName怎么用?C# JsonTextWriter.WritePropertyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Newtonsoft.Json.JsonTextWriter的用法示例。


在下文中一共展示了JsonTextWriter.WritePropertyName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Serialize

        public string Serialize()
        {
            var sb = new StringBuilder();
            var sw = new StringWriter(sb);

            using (JsonWriter jsonWriter = new JsonTextWriter(sw))
            {
                jsonWriter.Formatting = Formatting.Indented;

                jsonWriter.WriteStartObject();
                jsonWriter.WritePropertyName("public");
                jsonWriter.WriteValue(true);

                jsonWriter.WritePropertyName("files");

                jsonWriter.WriteStartObject();
                jsonWriter.WritePropertyName(File);

                jsonWriter.WriteStartObject();
                jsonWriter.WritePropertyName("content");
                jsonWriter.WriteValue(Code);
                jsonWriter.WriteEndObject();

                jsonWriter.WriteEndObject();

                jsonWriter.WriteEndObject();
            }

            return sb.ToString();
        }
开发者ID:perikete,项目名称:SendToGist,代码行数:30,代码来源:GistPublishRequest.cs

示例2: ToJson

 internal string ToJson()
 {
     StringBuilder sb = new StringBuilder();
     using (StringWriter sw = new StringWriter(sb))
     {
         using (JsonWriter jw = new JsonTextWriter(sw))
         {
             jw.WriteStartObject();
             if (!string.IsNullOrEmpty(AreaType))
             {
                 jw.WritePropertyName("areaType");
                 jw.WriteValue(AreaType);
             }
             if (!string.IsNullOrEmpty(BufferUnits))
             {
                 jw.WritePropertyName("bufferUnits");
                 jw.WriteValue(BufferUnits);
             }
             if (BufferRadii != null && BufferRadii.Count > 0)
             {
                 jw.WritePropertyName("Drives");
                 jw.WriteStartArray();
                 foreach (var radius in BufferRadii)
                     jw.WriteValue(radius);
                 jw.WriteEndArray();
             }
             jw.WriteEndObject();
         }
     }
     return sb.ToString();
 }
开发者ID:jNery,项目名称:geoenrichment_wp8,代码行数:31,代码来源:StudyAreaOptions.cs

示例3: WriteTo

        public static void WriteTo(this Item item, JsonTextWriter writer)
        {
            writer.WriteStartObject();

            writer.WritePropertyName(nameof(item.Format));
            writer.WriteValue(Enum.GetName(typeof(SecsFormat), item.Format));
            if (item.Format == SecsFormat.List)
            {
                writer.WritePropertyName(nameof(item.Items));
                writer.WriteStartArray();
                foreach (var subitem in item.Items)
                    subitem.WriteTo(writer);
                writer.WriteEndArray();
            }
            else
            {
                writer.WritePropertyName(nameof(item.Values));

                if (item.Format == SecsFormat.ASCII || item.Format == SecsFormat.JIS8)
                {
                    writer.WriteValue(item.GetValue<string>());
                }
                else
                {
                    writer.WriteStartArray();
                    foreach (var value in item.Values)
                        writer.WriteValue(value);
                    writer.WriteEndArray();
                }
            }
            writer.WriteEndObject();
        }
开发者ID:mkjeff,项目名称:secs4net,代码行数:32,代码来源:JsonExtension.cs

示例4: btnSend_Click

        protected void btnSend_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            JsonWriter jsonWriter = new JsonTextWriter(sw);

            jsonWriter.Formatting = Formatting.Indented;
            jsonWriter.WriteStartObject();
            jsonWriter.WritePropertyName("name");
            jsonWriter.WriteValue(txtName.Text);

            jsonWriter.WritePropertyName("description");
            jsonWriter.WriteValue(txtDesc.Text);

            jsonWriter.WritePropertyName("priority");
            jsonWriter.WriteValue((dpdPri.Text).ToUpper());

            jsonWriter.WriteEndObject();
            string output = sw.ToString();
            jsonWriter.Close();
            sw.Close();

            //string[] args = new string[3];
            //args[0] = txtName.Text;
            //args[1] = txtDesc.Text;
            //args[2] = txtPri.Text;
            //string message = string.Join(" ", args);
            byte[] body = System.Text.Encoding.UTF8.GetBytes(output);
            producer.SendMessage(body);
        }
开发者ID:qhodedemo,项目名称:UhuruRabbitMQDemo,代码行数:30,代码来源:default.aspx.cs

示例5: Get

        //https://webServiceURL/version/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier?passesUpdatedSince=tag
        public HttpResponseMessage Get(string version, string deviceLibraryIdentifier, string passTypeIdentifier, HttpRequestMessage request)
        {
            //List<string> updatedSerialNumbers = new List<string>();
            //updatedSerialNumbers.Add("121212111");

            //Dictionary<string, string> outputDictionary = new Dictionary<string, string>();
            //outputDictionary.Add("lastUpdated", "21/07/2012");
            //outputDictionary.Add("serialNumbers", JsonConvert.SerializeObject(updatedSerialNumbers));

            var response = new HttpResponseMessage(HttpStatusCode.OK);
            //string json = JsonConvert.SerializeObject(outputDictionary);


            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("lastUpdated");
                writer.WriteValue("21/07/2012");
                writer.WritePropertyName("serialNumbers");
                writer.WriteStartArray();
                writer.WriteValue("121212111");
                writer.WriteEndArray();
                writer.WriteEndObject();
            }

            response.Content = new StringContent(sb.ToString(), Encoding.UTF8, "application/json");

            return response;
        }
开发者ID:shanselman,项目名称:dotnet-passbook,代码行数:35,代码来源:PassRegistrationController.cs

示例6: DataTableToJSON

    public static string DataTableToJSON(DataTable dt, string dtName)
    {
        StringBuilder sb = new StringBuilder();
        StringWriter sw = new StringWriter(sb);

        using (JsonWriter jw = new JsonTextWriter(sw))
        {
            JsonSerializer ser = new JsonSerializer();
            jw.WriteStartObject();
            jw.WritePropertyName(dtName);
            jw.WriteStartArray();
            foreach (DataRow dr in dt.Rows)
            {
                jw.WriteStartObject();

                foreach (DataColumn dc in dt.Columns)
                {
                    jw.WritePropertyName(dc.ColumnName);
                    ser.Serialize(jw, dr[dc].ToString());
                }

                jw.WriteEndObject();
            }
            jw.WriteEndArray();
            jw.WriteEndObject();

            sw.Close();
            jw.Close();

        }

        return sb.ToString();
    }
开发者ID:ichari,项目名称:ichari,代码行数:33,代码来源:JsonHelper.cs

示例7: GenerateJson

        /// <summary>
        /// Generate the json output for the page.
        /// </summary>
        /// <param name="page">
        /// The page.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string GenerateJson(IContent page)
        {
            string json;

            List<KeyValuePair<string, string>> propertyValues = page.GetPropertyValues();

            StringBuilder stringBuilder = new StringBuilder();

            using (StringWriter sw = new StringWriter(stringBuilder, CultureInfo.InvariantCulture))
            {
                JsonWriter jsonWriter = new JsonTextWriter(sw) { Formatting = Formatting.Indented };

                jsonWriter.WriteStartObject();

                jsonWriter.WritePropertyName(page.Name);

                jsonWriter.WriteStartObject();

                foreach (KeyValuePair<string, string> content in propertyValues)
                {
                    jsonWriter.WritePropertyName(content.Key);
                    jsonWriter.WriteValue(TextIndexer.StripHtml(content.Value, content.Value.Length));
                }

                jsonWriter.WriteEndObject();

                jsonWriter.WriteEndObject();

                json = sw.ToString();
            }

            return json;
        }
开发者ID:jstemerdink,项目名称:EPiServer.Libraries,代码行数:42,代码来源:JsonOutputFormat.cs

示例8: CreateStatusText

	private string CreateStatusText()
	{
		using (var sw = new StringWriter())
		using (var jsonWriter = new JsonTextWriter(sw))
		{
			jsonWriter.WriteStartObject();
			{
				// Login
				jsonWriter.WritePropertyName("login");
				jsonWriter.WriteStartObject();
				{
					jsonWriter.WritePropertyName("port");
					jsonWriter.WriteValue(LoginServer.Instance.Conf.Login.Port);
				}
				jsonWriter.WriteEndObject();

				// Servers
				jsonWriter.WritePropertyName("servers");
				jsonWriter.WriteStartObject();
				{
					foreach (var server in LoginServer.Instance.ServerList.List)
					{
						// Channels
						jsonWriter.WritePropertyName(server.Name);
						jsonWriter.WriteStartObject();
						{
							foreach (var channel in server.Channels)
							{
								// Channel
								jsonWriter.WritePropertyName(channel.Key);
								jsonWriter.WriteStartObject();
								{
									jsonWriter.WritePropertyName("host");
									jsonWriter.WriteValue(channel.Value.Host);

									jsonWriter.WritePropertyName("port");
									jsonWriter.WriteValue(channel.Value.Port);

									jsonWriter.WritePropertyName("online");
									jsonWriter.WriteValue(channel.Value.Users);

									jsonWriter.WritePropertyName("onlineMax");
									jsonWriter.WriteValue(channel.Value.MaxUsers);

									jsonWriter.WritePropertyName("state");
									jsonWriter.WriteValue(channel.Value.State);
								}
								jsonWriter.WriteEndObject();
							}
						}
						jsonWriter.WriteEndObject();
					}
				}
				jsonWriter.WriteEndObject();
			}
			jsonWriter.WriteEndObject();

			return sw.ToString();
		}
	}
开发者ID:aura-project,项目名称:aura,代码行数:60,代码来源:status.cs

示例9: Main

 static void Main(string[] args)
 {
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     using (JsonWriter writer = new JsonTextWriter(sw))
     {
         writer.Formatting = Newtonsoft.Json.Formatting.Indented;
         writer.WriteStartObject();
         writer.WritePropertyName("CPU");
         writer.WriteValue("Intel");
         writer.WritePropertyName("PSU");
         writer.WriteValue("500W");
         writer.WritePropertyName("Drives");
         writer.WriteStartArray();
         writer.WriteValue("DVD read/writer");
         writer.WriteComment("(broken)");
         writer.WriteValue("500 gigabyte hard drive");
         writer.WriteValue("200 gigabype hard drive");
         writer.WriteEnd();
         writer.WriteEndObject();
     }
     File.WriteAllText(Environment.CurrentDirectory + "/rhcdata.json", sw.ToString());
     Console.WriteLine(sw.ToString());
     Console.ReadLine();
 }
开发者ID:MaurodeLyon,项目名称:Huiswerk-CSharp,代码行数:25,代码来源:Program.cs

示例10: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     string reVal = string.Empty;
     context.Response.ContentType = "text/plain";
     IEnumerable<ADM_USER> list = from m in etMgr.ADM_USER.OfType<ADM_USER>()
                                  select m;
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     using (JsonWriter jsonWriter = new JsonTextWriter(sw))
     {
         jsonWriter.Formatting = Formatting.Indented;
         jsonWriter.WriteStartArray();
         foreach (ADM_USER m in list)
         {
             jsonWriter.WriteStartObject();
             jsonWriter.WritePropertyName("name");
             jsonWriter.WriteValue(string.IsNullOrEmpty(m.REAL_NAME) ? m.USERNAME : m.REAL_NAME);
             jsonWriter.WritePropertyName("id");
             jsonWriter.WriteValue(m.USER_ID);
             jsonWriter.WriteEndObject();
         }
         jsonWriter.WriteEnd();
     }
     reVal = sb.ToString();
     context.Response.Write(reVal);
 }
开发者ID:mxm2005,项目名称:oacrm,代码行数:26,代码来源:GetUsers.ashx.cs

示例11: MapFromAttributes

        internal string MapFromAttributes()
        {
            var sb = new StringBuilder();
            using (StringWriter sw = new StringWriter(sb))
            using (JsonWriter jsonWriter = new JsonTextWriter(sw))
            {
                jsonWriter.Formatting = Formatting.Indented;
                jsonWriter.WriteStartObject();
                {
                    var typeName = this.TypeName.Resolve(this._connectionSettings);
                    jsonWriter.WritePropertyName(typeName);
                    jsonWriter.WriteStartObject();
                    {
                        this.WriteRootObjectProperties(jsonWriter);

                        jsonWriter.WritePropertyName("properties");
                        jsonWriter.WriteStartObject();
                        {
                            this.WriteProperties(jsonWriter);
                        }
                        jsonWriter.WriteEnd();
                    }
                    jsonWriter.WriteEnd();
                }
                jsonWriter.WriteEndObject();

                return sw.ToString();
            }
        }
开发者ID:Rustemt,项目名称:NEST,代码行数:29,代码来源:TypeMappingWriter.cs

示例12: parameterFieldMapJson

        /// <summary>
        /// Convert parameter list to json object
        /// </summary>
        public static string parameterFieldMapJson(parameters parms, string ProjectID, string QueryID)
        {
            StringWriter sw = new StringWriter();
            JsonTextWriter json = new JsonTextWriter(sw);

            json.WriteStartObject();
            json.WritePropertyName("results");
            json.WriteStartArray();
            json.WriteStartObject();
            // ProjectID and QueryID
            json.WritePropertyName("ProjectID");
            json.WriteValue(ProjectID);
            json.WritePropertyName("QueryID");
            json.WriteValue(QueryID);

            json.WritePropertyName("parameters");
            json.WriteRawValue(JsonConvert.SerializeObject(parms));

            json.WriteEndObject();
            json.WriteEndArray();
            json.WriteEndObject();

            json.Flush();
            sw.Flush();

            return sw.ToString();
        }
开发者ID:kstubs,项目名称:ProjFlx,代码行数:30,代码来源:Helper.cs

示例13: ToJson

 internal string ToJson()
 {
     StringBuilder sb = new StringBuilder();
     using (StringWriter sw = new StringWriter(sb))
     {
         using (JsonWriter jw = new JsonTextWriter(sw))
         {
             jw.WriteStartObject();
             if (GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.Point || GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.Polygon)
             {
                 jw.WritePropertyName("geometryType");
                 jw.WriteValue(string.Format("esriGeometry{0}", GeometryType));
             }
             jw.WritePropertyName("spatialRel");
             jw.WriteValue(SpatialRelationship.ToString());
             if (!string.IsNullOrEmpty(Where))
             {
                 jw.WritePropertyName("where");
                 jw.WriteValue(Where);
             }
             jw.WriteEndObject();
         }
     }
     return sb.ToString();
 }
开发者ID:jNery,项目名称:geoenrichment_wp8,代码行数:25,代码来源:IntersectingInfo.cs

示例14: DeleteFromIndex

        public override bool DeleteFromIndex(ISearchableItem item)
        {
            Initialise();

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);

            using (JsonTextWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("delete");
                writer.WriteStartObject();

                writer.WritePropertyName("id");
                writer.WriteValue(item.ItemKey.TypeId.ToString() + "," + item.Id.ToString());

                writer.WriteEndObject();
                writer.WriteEndObject();
            }

            try
            {
                WebClient wc = new WebClient();
                wc.Headers[HttpRequestHeader.ContentType] = "type:application/json";
                wc.UploadString("http://" + server + "/update/json", sb.ToString());
                wc.DownloadString("http://" + server + "/update?commit=true");
            }
            catch
            {
            }

            return true;
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:35,代码来源:SolrSearch.cs

示例15: BasicRequest

		//JsonWriter writer = new JsonTextWriter();
		protected static string BasicRequest(int requestID, string method, string sessionID, params string[] parameters)
		{
			StringBuilder sb = new StringBuilder();
			StringWriter sw = new StringWriter(sb);

			using (JsonWriter writer = new JsonTextWriter(sw))
			{
				writer.Formatting = Formatting.Indented;

				writer.WriteStartObject();
				writer.WritePropertyName("jsonrpc");
				writer.WriteValue("2.0");
				writer.WritePropertyName("id");
				writer.WriteValue(requestID);
				writer.WritePropertyName("method");
				writer.WriteValue(method);
				writer.WritePropertyName("params");
				writer.WriteStartArray();
				writer.WriteValue(sessionID);
				foreach (var p in parameters)
					writer.WriteValue(p);
				writer.WriteEndArray();
				writer.WriteEndObject();
                return sb.ToString();
				//return sb.ToString().Replace("\n","");
			}
		}
开发者ID:Jazzeroki,项目名称:LacunaExpressXamarin,代码行数:28,代码来源:CoreClass.cs


注:本文中的Newtonsoft.Json.JsonTextWriter.WritePropertyName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。