Ejemplo n.º 1
0
        } // End Sub TestCompleteness

        public static async System.Threading.Tasks.Task TestJsonGeneration2()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            using (System.IO.StringWriter sw = new System.IO.StringWriter(sb))
            {
                using (Newtonsoft.Json.JsonTextWriter jsonWriter = new Newtonsoft.Json.JsonTextWriter(sw))
                {
                    jsonWriter.Formatting = Newtonsoft.Json.Formatting.Indented;

                    // await jsonWriter.WriteStartObjectAsync();


                    jsonWriter.WriteRaw("{");



                    jsonWriter.WriteRaw(System.Environment.NewLine);

                    await jsonWriter.WritePropertyNameAsync("key");

                    await jsonWriter.WriteValueAsync("value");


                    await jsonWriter.WritePropertyNameAsync("key 2");

                    await jsonWriter.WriteValueAsync("value 2");

                    jsonWriter.WriteRaw(System.Environment.NewLine);
                    jsonWriter.WriteRaw("}");
                    jsonWriter.WriteRaw(System.Environment.NewLine);



                    jsonWriter.WriteRaw(",bar:{");
                    jsonWriter.WriteRaw(System.Environment.NewLine);

                    await jsonWriter.WritePropertyNameAsync("key");

                    await jsonWriter.WriteValueAsync("value");


                    await jsonWriter.WritePropertyNameAsync("key 2");

                    await jsonWriter.WriteValueAsync("value 2");

                    jsonWriter.WriteRaw(System.Environment.NewLine);
                    jsonWriter.WriteRaw("}");
                    jsonWriter.WriteRaw(System.Environment.NewLine);

                    // await jsonWriter.WriteEndObjectAsync();
                } // End Using jsonWriter
            }     // End Using sw

            string txt = sb.ToString();

            System.Console.WriteLine(txt);
        } // End Sub TestJsonGeneration2