Exemple #1
0
        /// <summary>
        /// Writes a text representation of the specified <paramref name="objectValue"/> into a text writer.
        /// </summary>
        /// <param name="objectValue">The JSON value to write.</param>
        private void WriteObject(JsonObject objectValue)
        {
            var startObjectTextAnnotation = objectValue.GetAnnotation <JsonStartObjectTextAnnotation>()
                                            ?? JsonStartObjectTextAnnotation.GetDefault(this.writer);
            var endObjectTextAnnotation = objectValue.GetAnnotation <JsonEndObjectTextAnnotation>()
                                          ?? JsonEndObjectTextAnnotation.GetDefault(this.writer);

            this.writer.Write(startObjectTextAnnotation.Text);

            bool first = true;

            foreach (JsonProperty propertyValue in objectValue.Properties)
            {
                var propertySeparatorTextAnnotation = propertyValue.GetAnnotation <JsonPropertySeparatorTextAnnotation>()
                                                      ?? JsonPropertySeparatorTextAnnotation.GetDefault(first);
                first = false;

                this.writer.Write(propertySeparatorTextAnnotation.Text);
                this.WriteValue(propertyValue);
            }

            this.writer.Write(endObjectTextAnnotation.Text);
        }