Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Indent ¶
func Indent(body io.ReadCloser, h http.Header, prefix, indent string) (io.ReadCloser, error)
Example ¶
package main
import (
"bytes"
"fmt"
"github.com/behavioral-ai/core/iox"
"io"
)
const (
customerAddr = "file://[cwd]/jsontest/customer-address.txt"
)
func main() {
buf, status := iox.ReadFile(customerAddr)
fmt.Printf("test: iox.ReadFile() -> [status:%v] %v\n", status, string(buf))
if status == nil {
//fmt.Printf("test:")
c := io.NopCloser(bytes.NewReader(buf))
c2, status1 := Indent(c, nil, "", " ")
if status1 == nil {
buf2, status2 := iox.ReadAll(c2, nil)
fmt.Printf("test: Indent() -> [status:%v] %v\n", status2, string(buf2))
}
}
}
Output: test: iox.ReadFile() -> [status:<nil>] [{"customer-id":"C001","created-ts":"0001-01-01T00:00:00Z","address-1":"1514 Cedar Ridge Road","address-2":"","city":"Vinton","state":"IA","postal-code":"52349","email":"before-email@hotmail.com"}] test: Indent() -> [status:<nil>] [ { "customer-id": "C001", "created-ts": "0001-01-01T00:00:00Z", "address-1": "1514 Cedar Ridge Road", "address-2": "", "city": "Vinton", "state": "IA", "postal-code": "52349", "email": "before-email@hotmail.com" } ]
func New ¶
New - create a new type from JSON content, supporting: string, *url.URL, []byte, io.Reader, io.ReadCloser
func NewReadCloser ¶
func NewReadCloser(v any) (io.ReadCloser, int64, error)
NewReadCloser - create an io.ReadCloser from a type
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.