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


C# JsonWriter.WriteString方法代码示例

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


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

示例1: WriteRssToJson

 private static void WriteRssToJson(Channel channel, JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WriteMember("title");
     writer.WriteString(channel.title);
     writer.WriteMember("link");
     writer.WriteString(channel.link);
     writer.WriteMember("items");
     writer.WriteStartArray();
     foreach (Item item in channel.item)
         WriteRssToJson(item, writer);
     writer.WriteEndArray();
     writer.WriteEndObject();
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:14,代码来源:Program.cs

示例2: WritePhoneNumber

 private static void WritePhoneNumber(JsonWriter writer, string location, string number)
 {
     writer.WriteStartObject();      //  {
     writer.WriteMember("Location"); //      "Location" :
     writer.WriteString(location);   //          "...",
     writer.WriteMember("Number");   //      "Number" :
     writer.WriteString(number);     //          "..."
     writer.WriteEndObject();        //  }
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:9,代码来源:Program.cs

示例3: FormatCustom

 protected virtual void FormatCustom(object o, JsonWriter writer)
 {
     writer.WriteString(Convert.ToString(o, CultureInfo.InvariantCulture));
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:4,代码来源:JsonFormatter.cs

示例4: FormatString

 protected virtual void FormatString(string value, JsonWriter writer)
 {
     writer.WriteString(value);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:4,代码来源:JsonFormatter.cs

示例5: ExportValue

            protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
            {
                IEnumerable enumerable = (IEnumerable) value;

                ArrayList list = new ArrayList();

                foreach (object item in enumerable)
                    list.Add(item == null ? null : item.ToString());

                writer.WriteString(string.Join(",", (string[]) list.ToArray(typeof(string))));
            }
开发者ID:bubbafat,项目名称:Hebo,代码行数:11,代码来源:TestJsonTextWriter.cs

示例6: FormatOther

        protected virtual void FormatOther(object o, JsonWriter writer)
        {
            //
            // If the value is is JSON-aware then let it do the job.
            //

            IJsonFormattable jsonFormattable = o as IJsonFormattable;

            if (jsonFormattable != null)
            {
                FormatFormattable(jsonFormattable, writer);
                return;
            }

            //
            // If the value is a dictionary then encode it as a JSON
            // object.
            //

            IDictionary dictionary = o as IDictionary;

            if (dictionary != null)
            {
                FormatDictionary(dictionary, writer);
                return;
            }

            //
            // If the value is enumerable then encode it as a JSON
            // array.
            //

            IEnumerable enumerable = o as IEnumerable;

            if (enumerable != null)
            {
                FormatEnumerable(enumerable, writer);
                return;
            }

            //
            // For all other types, write out its string representation as a
            // simple JSON string.
            //
            
            writer.WriteString(Convert.ToString(o, CultureInfo.InvariantCulture));
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:47,代码来源:JsonFormatter.cs

示例7: Export

        /// <summary>
        /// The export.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="writer">
        /// The writer.
        /// </param>
        public void Export(ExportContext context, object value, JsonWriter writer)
        {
            writer.WriteStartObject();
            writer.WriteMember("Critter");

            var critter = (Critter)value;
            writer.WriteStartObject();

            if (exportType > ExportType.Expanded)
            {
                writer.WriteMember("Age");
                writer.WriteNumber(critter.Age);
                writer.WriteMember("N");
                writer.WriteNumber(critter.N);
            }

            writer.WriteMember("Rank");
            writer.WriteNumber(critter.Rank);

            writer.WriteMember("Fitness");
            writer.WriteStartObject();
            int i = 0;
            foreach (var n in Enum.GetNames(typeof(FitnessParameter)))
            {
                writer.WriteMember(n);
                writer.WriteNumber(critter.Fitness[i++]);
            }

            writer.WriteEndObject();

            // writer.WriteMember("Fitness");
            // context.Export(critter.Fitness,writer);
            if (exportType > ExportType.Summary)
            {
                writer.WriteMember("Route");
                writer.WriteStartArray();
                foreach (var node in critter.Route)
                {
                    writer.WriteNumber(node.Node.Id);
                }
                writer.WriteEndArray();
            }

            writer.WriteMember("Legs");
            writer.WriteStartArray();
            foreach (var leg in critter.Fitness.JourneyLegs)
            {
                writer.WriteStartObject();

                if (exportType > ExportType.Summary)
                {
                    writer.WriteMember("Start");
                    writer.WriteNumber(leg.Origin.Id);
                    writer.WriteMember("End");
                    writer.WriteNumber(leg.Destination.Id);
                    writer.WriteMember("Route");
                    writer.WriteString(leg.RouteId1);
                }

                if (exportType > ExportType.Simple)
                {
                    writer.WriteMember("StartLocation");
                    writer.WriteStartObject();
                    writer.WriteMember("Lat");
                    writer.WriteNumber(leg.Origin.Latitude);
                    writer.WriteMember("Long");
                    writer.WriteNumber(leg.Origin.Longitude);

                    writer.WriteEndObject();

                    writer.WriteMember("EndLocation");
                    writer.WriteStartObject();
                    writer.WriteMember("Lat");
                    writer.WriteNumber(leg.Destination.Latitude);
                    writer.WriteMember("Long");
                    writer.WriteNumber(leg.Destination.Longitude);
                    writer.WriteEndObject();
                }

                writer.WriteMember("Mode");
                writer.WriteString(leg.TransportMode.ToString());
                writer.WriteMember("TotalTime");
                context.Export(leg.TotalTime, writer);
                writer.WriteMember("DepartTime");
                context.Export(leg.DepartureTime, writer);
                writer.WriteMember("OriginName");
                writer.WriteString(leg.Origin.StopSpecName);

//.........这里部分代码省略.........
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:101,代码来源:CritterExporter.cs

示例8: ExportValue

 protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
 {
     //writer.WriteString(((DateTime)value).ToString("yyyy-MM-dd hh:mm:ss"));
     writer.WriteString(((DateTime)value).ToString("s"));
 }
开发者ID:fishonline,项目名称:API-1,代码行数:5,代码来源:JsonConverters.cs


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