Files
next.orly.dev/pkg/encoders/json/jsontext/quote.go
mleku a4c4f14b87
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled
Refactor event processing in tests for chronological order
- Updated test files to collect events first and sort them by their CreatedAt timestamp before processing, ensuring events are handled in chronological order.
- Removed redundant error checks for scanner errors after event processing.
- Enhanced clarity and maintainability of event handling in tests across multiple files, including export, fetch, and query tests.
- Adjusted expected index counts in tests to reflect changes in event structure and processing logic.
2025-10-16 15:05:19 +01:00

42 lines
1.6 KiB
Go

// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build goexperiment.jsonv2
package jsontext
import (
"next.orly.dev/pkg/json/internal/jsonflags"
"next.orly.dev/pkg/json/internal/jsonwire"
)
// AppendQuote appends a double-quoted JSON string literal representing src
// to dst and returns the extended buffer.
// It uses the minimal string representation per RFC 8785, section 3.2.2.2.
// Invalid UTF-8 bytes are replaced with the Unicode replacement character
// and an error is returned at the end indicating the presence of invalid UTF-8.
// The dst must not overlap with the src.
func AppendQuote[Bytes ~[]byte | ~string](dst []byte, src Bytes) ([]byte, error) {
dst, err := jsonwire.AppendQuote(dst, src, &jsonflags.Flags{})
if err != nil {
err = &SyntacticError{Err: err}
}
return dst, err
}
// AppendUnquote appends the decoded interpretation of src as a
// double-quoted JSON string literal to dst and returns the extended buffer.
// The input src must be a JSON string without any surrounding whitespace.
// Invalid UTF-8 bytes are replaced with the Unicode replacement character
// and an error is returned at the end indicating the presence of invalid UTF-8.
// Any trailing bytes after the JSON string literal results in an error.
// The dst must not overlap with the src.
func AppendUnquote[Bytes ~[]byte | ~string](dst []byte, src Bytes) ([]byte, error) {
dst, err := jsonwire.AppendUnquote(dst, src)
if err != nil {
err = &SyntacticError{Err: err}
}
return dst, err
}