Ejemplo n.º 1
0
        /// <summary>
        /// Make an JSON external form string of this JsonArray. For
        /// compactness, no unnecessary whitespace is added.
        /// </summary>
        /// <remarks>
        /// This method assumes that the data structure is acyclical.
        /// </remarks>

        public override string ToString()
        {
            StringWriter writer = new StringWriter();

            Export(JsonText.CreateWriter(writer));
            return(writer.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the content of the buffer formatted as JSON text.
        /// </summary>

        public override string ToString()
        {
            if (IsEmpty)
            {
                return(string.Empty);
            }
            if (IsNull)
            {
                return(JsonNull.Text);
            }
            if (FirstToken.Class == JsonTokenClass.String)
            {
                return(JsonString.Enquote(FirstToken.Text));
            }
            if (IsScalar)
            {
                return(FirstToken.Text);
            }
            StringBuilder sb = new StringBuilder();

            JsonText.CreateWriter(sb).WriteFromReader(CreateReader());
            return(sb.ToString());
        }