/// <summary>
        /// Asynchronously writes the json array value.
        /// </summary>
        /// <param name="jsonWriter">The <see cref="JsonWriter"/> to write to.</param>
        /// <param name="arrayValue">Writes the json array value to the underlying json writer.</param>
        /// <returns>A task that represents the asynchronous write operation.</returns>
        private static async Task WriteJsonArrayValueAsync(this IJsonWriterAsync jsonWriter, IEnumerable arrayValue)
        {
            Debug.Assert(arrayValue != null, "arrayValue != null");

            await jsonWriter.StartArrayScopeAsync().ConfigureAwait(false);

            foreach (object element in arrayValue)
            {
                await jsonWriter.WriteJsonValueAsync(element).ConfigureAwait(false);
            }

            await jsonWriter.EndArrayScopeAsync().ConfigureAwait(false);
        }
        /// <summary>
        /// Asynchronously writes the json object value to the <paramref name="jsonWriter"/>.
        /// </summary>
        /// <param name="jsonWriter">The <see cref="JsonWriter"/> to write to.</param>
        /// <param name="jsonObjectValue">Writes the given json object value to the underlying json writer.</param>
        /// <param name="injectPropertyDelegate">Called when the top-level object is started to possibly inject first property into the object.</param>
        /// <returns>A task that represents the asynchronous write operation.</returns>
        internal static async Task WriteJsonObjectValueAsync(
            this IJsonWriterAsync jsonWriter,
            IDictionary <string, object> jsonObjectValue,
            Func <IJsonWriterAsync, Task> injectPropertyDelegate)
        {
            Debug.Assert(jsonWriter != null, "jsonWriter != null");
            Debug.Assert(jsonObjectValue != null, "jsonObjectValue != null");

            await jsonWriter.StartObjectScopeAsync().ConfigureAwait(false);

            if (injectPropertyDelegate != null)
            {
                await injectPropertyDelegate(jsonWriter).ConfigureAwait(false);
            }

            foreach (KeyValuePair <string, object> property in jsonObjectValue)
            {
                await jsonWriter.WriteNameAsync(property.Key).ConfigureAwait(false);

                await jsonWriter.WriteJsonValueAsync(property.Value).ConfigureAwait(false);
            }

            await jsonWriter.EndObjectScopeAsync().ConfigureAwait(false);
        }