System.Json.JsonValue.SaveInternal C# (CSharp) Method

SaveInternal() private method

private SaveInternal ( TextWriter w ) : void
w System.IO.TextWriter
return void
        private void SaveInternal(TextWriter w)
        {
            switch (JsonType)
            {
                case JsonType.Object:
                    w.Write('{');
                    bool following = false;
                    foreach (JsonPair pair in ((JsonObject)this))
                    {
                        if (following)
                        {
                            w.Write(", ");
                        }

                        w.Write('\"');
                        w.Write(EscapeString(pair.Key));
                        w.Write("\": ");
                        if (pair.Value == null)
                        {
                            w.Write("null");
                        }
                        else
                        {
                            pair.Value.SaveInternal(w);
                        }

                        following = true;
                    }
                    w.Write('}');
                    break;

                case JsonType.Array:
                    w.Write('[');
                    following = false;
                    foreach (JsonValue v in ((JsonArray)this))
                    {
                        if (following)
                        {
                            w.Write(", ");
                        }

                        if (v != null)
                        {
                            v.SaveInternal(w);
                        }
                        else
                        {
                            w.Write("null");
                        }

                        following = true;
                    }
                    w.Write(']');
                    break;

                case JsonType.Boolean:
                    w.Write(this ? "true" : "false");
                    break;

                case JsonType.String:
                    w.Write('"');
                    w.Write(EscapeString(((JsonPrimitive)this).GetFormattedString()));
                    w.Write('"');
                    break;

                default:
                    w.Write(((JsonPrimitive)this).GetFormattedString());
                    break;
            }
        }