private static void WriterSystemTextJsonBasicUtf8(bool formatted, ArrayFormatterWrapper output, ReadOnlySpan <int> data) { Utf8JsonWriter <ArrayFormatterWrapper> json = Utf8JsonWriter.Create(output, formatted); json.WriteObjectStart(); json.WriteAttribute("age", 42); json.WriteAttribute("first", "John"); json.WriteAttribute("last", "Smith"); json.WriteArrayStart("phoneNumbers"); json.WriteValue("425-000-1212"); json.WriteValue("425-000-1213"); json.WriteArrayEnd(); json.WriteObjectStart("address"); json.WriteAttribute("street", "1 Microsoft Way"); json.WriteAttribute("city", "Redmond"); json.WriteAttribute("zip", 98052); json.WriteObjectEnd(); json.WriteArrayStart("ExtraArray"); for (var i = 0; i < data.Length; i++) { json.WriteValue(data[i]); } json.WriteArrayEnd(); json.WriteObjectEnd(); json.Flush(); }
private static void WriterSystemTextJsonArrayOnlyUtf8(bool formatted, ArrayFormatterWrapper output, ReadOnlySpan <int> data) { Utf8JsonWriter <ArrayFormatterWrapper> json = Utf8JsonWriter.Create(output, formatted); json.WriteArrayUtf8(ExtraArray, data); json.Flush(); }
private static void WriterSystemTextJsonHelloWorldUtf8(bool formatted, ArrayFormatterWrapper output) { Utf8JsonWriter <ArrayFormatterWrapper> json = Utf8JsonWriter.Create(output, formatted); json.WriteObjectStart(); json.WriteAttribute("message", "Hello, World!"); json.WriteObjectEnd(); json.Flush(); }
private static void WriterSystemTextJsonArrayOnlyUtf8(bool formatted, ArrayFormatterWrapper output, ReadOnlySpan <int> data) { Utf8JsonWriter <ArrayFormatterWrapper> json = Utf8JsonWriter.Create(output, formatted); json.WriteArrayStart("ExtraArray"); for (var i = 0; i < data.Length; i++) { json.WriteValue(data[i]); } json.WriteArrayEnd(); json.Flush(); }