package json
import "git.sr.ht/~shulhan/pakakeh.go/lib/json"
Package json provide a library for working with JSON.
This is an extension to standard "encoding/json" package.
Index ¶
- func Escape(in []byte) []byte
- func EscapeString(in string) string
- func ToMapStringFloat64(in map[string]any) (out map[string]float64, err error)
- func Unescape(in []byte, strict bool) (out []byte, err error)
- func UnescapeString(in string, strict bool) (string, error)
Functions ¶
func Escape ¶
Escape the following character: `"` (quotation mark), `\` (reverse solidus), `\b` (backspace), `\f` (formfeed), `\n` (newline), `\r` (carriage return`), `\t` (horizontal tab), and control character from 0 - 31.
References:
* https://tools.ietf.org/html/rfc7159#page-8
func EscapeString ¶
EscapeString escape the following character: `"` (quotation mark), `\` (reverse solidus), `\b` (backspace), `\f` (formfeed), `\n` (newline), `\r` (carriage return`), `\t` (horizontal tab), and control character from 0 - 31.
References
* https://tools.ietf.org/html/rfc7159#page-8
func ToMapStringFloat64 ¶
ToMapStringFloat64 convert the map of string-any into map of string-float64. This function convert the map's key to lower-cases and ignore zero value in any. The any value only accept basic numeric types and slice of byte.
func Unescape ¶
Unescape JSON bytes, reversing what Escape function do.
If strict is true, any unknown control character will be returned as error. For example, in string "\x", "x" is not valid control character, and the function will return empty string and error. If strict is false, it will return "x".
func UnescapeString ¶
UnescapeString unescape JSON string, reversing what EscapeString do.
If strict is true, any unknown control character will be returned as error. For example, in string "\x", "x" is not valid control character, and the function will return empty string and error. If strict is false, it will return "x".
Source Files ¶
- Version
- v0.60.0 (latest)
- Published
- Feb 1, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 25 minutes ago –
Tools for package owners.