/// <summary>
        /// Parses Json value or property.
        /// </summary>
        /// <returns>Parsed value.</returns>
        public JsonValue ParseValueOrProperty()
        {
            JsonValue          value       = this.ParseValue();
            JsonPrimitiveValue stringValue = value as JsonPrimitiveValue;

            if (stringValue != null && stringValue.Value != null && stringValue.Value is string)
            {
                if (this.tokenizer.HasMoreTokens())
                {
                    JsonPrimitiveValueTextAnnotation textAnnotation             = stringValue.GetAnnotation <JsonPrimitiveValueTextAnnotation>();
                    JsonPropertyNameTextAnnotation   propertyNameTextAnnotation = null;
                    if (textAnnotation != null)
                    {
                        propertyNameTextAnnotation = new JsonPropertyNameTextAnnotation()
                        {
                            Text = textAnnotation.Text
                        };
                    }

                    return(this.ParsePropertyWithName((string)stringValue.Value, propertyNameTextAnnotation));
                }
                else
                {
                    return(stringValue);
                }
            }
            else
            {
                return(value);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Writes a text representation of the specified <paramref name="primitiveValue"/> into a text writer.
        /// </summary>
        /// <param name="primitiveValue">The JSON value to write.</param>
        private void WritePrimitiveValue(JsonPrimitiveValue primitiveValue)
        {
            var textAnnotation = primitiveValue.GetAnnotation <JsonPrimitiveValueTextAnnotation>()
                                 ?? JsonPrimitiveValueTextAnnotation.GetDefault(primitiveValue, this.writingJsonLight, isIeee754Compatible);

            this.writer.Write(textAnnotation.Text);
        }
 /// <summary>
 /// Writes a text representation of the specified <paramref name="primitiveValue"/> into a text writer.
 /// </summary>
 /// <param name="primitiveValue">The JSON value to write.</param>
 private void WritePrimitiveValue(JsonPrimitiveValue primitiveValue)
 {
     var textAnnotation = primitiveValue.GetAnnotation<JsonPrimitiveValueTextAnnotation>()
         ?? JsonPrimitiveValueTextAnnotation.GetDefault(primitiveValue, this.writingJsonLight, isIeee754Compatible);
     this.writer.Write(textAnnotation.Text);
 }