Ejemplo n.º 1
0
        /// <summary>
        /// Sets json property annotation text with whitespaces.
        /// </summary>
        /// <param name="transformedPayload">Transformed payload with json annotations.</param>
        private void SetWhiteSpaceJsonPropertyAnnotations(JsonValue transformedPayload)
        {
            JsonPropertyNameValueSeparatorTextAnnotation jsonPropertyNameValueSeparatorTextAnnotation = new JsonPropertyNameValueSeparatorTextAnnotation();

            jsonPropertyNameValueSeparatorTextAnnotation.Text = "\t\n : \t\n";
            transformedPayload.SetAnnotation <JsonPropertyNameValueSeparatorTextAnnotation>(jsonPropertyNameValueSeparatorTextAnnotation);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes a text representation of the specified <paramref name="propertyValue"/> into a text writer.
        /// </summary>
        /// <param name="propertyValue">The JSON value to write.</param>
        private void WriteProperty(JsonProperty propertyValue)
        {
            var nameTextAnnotation = propertyValue.GetAnnotation <JsonPropertyNameTextAnnotation>()
                                     ?? JsonPropertyNameTextAnnotation.GetDefault(propertyValue.Name);
            var nameValueSeparatorTextAnnotation = propertyValue.GetAnnotation <JsonPropertyNameValueSeparatorTextAnnotation>()
                                                   ?? JsonPropertyNameValueSeparatorTextAnnotation.GetDefault();

            this.writer.Write(nameTextAnnotation.Text);
            this.writer.Write(nameValueSeparatorTextAnnotation.Text);
            this.WriteValue(propertyValue.Value);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses a property starting with the colon after the property name.
        /// </summary>
        /// <param name="propertyName">The name of the property.</param>
        /// <param name="propertyNameTextAnnotation">The name text annotation for the property.</param>
        /// <returns>parsed object</returns>
        private JsonProperty ParsePropertyWithName(string propertyName, JsonPropertyNameTextAnnotation propertyNameTextAnnotation)
        {
            // Each name is followed by : (colon)
            ExceptionUtilities.Assert(this.tokenizer.TokenType == JsonTokenType.Colon, "Invalid Token");

            var nameValueSeparatorTextAnnotation = new JsonPropertyNameValueSeparatorTextAnnotation()
            {
                Text = this.tokenizer.TokenText
            };

            this.tokenizer.GetNextToken();

            // Colon is followed by a value
            ExceptionUtilities.Assert(this.IsValueType(this.tokenizer.TokenType), "Invalid Token");

            JsonValue value    = this.ParseValue();
            var       property = new JsonProperty(propertyName, value);

            property.SetAnnotation(propertyNameTextAnnotation);
            property.SetAnnotation(nameValueSeparatorTextAnnotation);

            return(property);
        }