Exemple #1
0
        private void WriteCommentWithEncodingValue(ReadOnlySpan <byte> value)
        {
            //TODO: Add ReadOnlySpan<char> overload to this check
            if (JsonWriterHelper.IndexOfAnyEscape(value) != -1)
            {
                value = JsonWriterHelper.EscapeStringValue(value);
            }

            if (_writerOptions.Formatted)
            {
                WriteCommentFormattedWithEncodingValue(ref value);
            }
            else
            {
                WriteCommentFastWithEncodingValue(ref value);
            }
        }
Exemple #2
0
        public void WriteComment(ReadOnlySpan <byte> utf8Text)
        {
            JsonWriterHelper.ValidateValue(ref utf8Text);

            if (JsonWriterHelper.IndexOfAnyEscape(utf8Text) != -1)
            {
                //TODO: Add escaping.
                utf8Text = JsonWriterHelper.EscapeStringValue(utf8Text);
            }

            if (_writerOptions.Formatted)
            {
                WriteCommentFormatted(ref utf8Text);
            }
            else
            {
                WriteCommentFast(ref utf8Text);
            }
        }
Exemple #3
0
        private void WriteValueWithEncodingValue(ReadOnlySpan <byte> value)
        {
            //TODO: Add ReadOnlySpan<char> overload to this check
            if (JsonWriterHelper.IndexOfAnyEscape(value) != -1)
            {
                value = JsonWriterHelper.EscapeStringValue(value);
            }

            if (_writerOptions.SlowPath)
            {
                WriteValueSlowWithEncodingValue(ref value);
            }
            else
            {
                WriteValueFastWithEncodingValue(ref value);
            }

            _currentDepth |= 1 << 31;
            _tokenType     = JsonTokenType.String;
        }
Exemple #4
0
        public void WriteValue(ReadOnlySpan <byte> utf8Text)
        {
            JsonWriterHelper.ValidateValue(ref utf8Text);

            if (JsonWriterHelper.IndexOfAnyEscape(utf8Text) != -1)
            {
                //TODO: Add escaping.
                utf8Text = JsonWriterHelper.EscapeStringValue(utf8Text);
            }

            if (_writerOptions.SlowPath)
            {
                WriteValueSlow(ref utf8Text);
            }
            else
            {
                WriteValueFast(ref utf8Text);
            }

            _currentDepth |= 1 << 31;
            _tokenType     = JsonTokenType.String;
        }