Involved Source Filesarena.go
Package fastjson provides fast JSON parsing.
Arbitrary JSON may be parsed by fastjson without the need for creating structs
or for generating go code. Just parse JSON and get the required fields with
Get* functions.
handy.goparser.gopool.goscanner.goupdate.goutil.govalidate.go
Package-Level Type Names (total 10, in which 8 are exported)
/* sort exporteds by: | */
Arena may be used for fast creation and re-use of Values.
Typical Arena lifecycle:
1) Construct Values via the Arena and Value.Set* calls.
2) Marshal the constructed Values with Value.MarshalTo call.
3) Reset all the constructed Values at once by Arena.Reset call.
4) Go to 1 and re-use the Arena.
It is unsafe calling Arena methods from concurrent goroutines.
Use per-goroutine Arenas or ArenaPool instead.
b[]byteccache
NewArray returns new empty array value.
New entries may be added to the returned array via Set* calls.
The returned array is valid until Reset is called on a.
NewFalse return false value.
NewNull returns null value.
NewNumberFloat64 returns new number value containing f.
The returned number is valid until Reset is called on a.
NewNumberInt returns new number value containing n.
The returned number is valid until Reset is called on a.
NewNumberString returns new number value containing s.
The returned number is valid until Reset is called on a.
NewObject returns new empty object value.
New entries may be added to the returned object via Set call.
The returned object is valid until Reset is called on a.
NewString returns new string value containing s.
The returned string is valid until Reset is called on a.
NewStringBytes returns new string value containing b.
The returned string is valid until Reset is called on a.
NewTrue returns true value.
Reset resets all the Values allocated by a.
Values previously allocated by a cannot be used after the Reset call.
func (*ArenaPool).Get() *Arena
func (*ArenaPool).Put(a *Arena)
ArenaPool may be used for pooling Arenas for similarly typed JSONs.
poolsync.Pool
Get returns an Arena from ap.
The Arena must be Put to ap after use.
Put returns a to ap.
a and objects created by a cannot be used after a is put into ap.
Object represents JSON object.
Object cannot be used from concurrent goroutines.
Use per-goroutine parsers or ParserPool instead.
keysUnescapedboolkvs[]kv
Del deletes the entry with the given key from o.
Get returns the value for the given key in the o.
Returns nil if the value for the given key isn't found.
The returned value is valid until Parse is called on the Parser returned o.
Len returns the number of items in the o.
MarshalTo appends marshaled o to dst and returns the result.
Set sets (key, value) entry in the o.
The value must be unchanged during o lifetime.
String returns string representation for the o.
This function is for debugging purposes only. It isn't optimized for speed.
See MarshalTo instead.
Visit calls f for each item in the o in the original order
of the parsed JSON.
f cannot hold key and/or v after returning.
(*Object) getKV() *kv(*Object) reset()(*Object) unescapeKeys()
*Object : expvar.Var
*Object : fmt.Stringer
*Object : github.com/aws/smithy-go/middleware.stringer
*Object : context.stringer
*Object : runtime.stringer
func (*Value).GetObject(keys ...string) *Object
func (*Value).Object() (*Object, error)
func go.pact.im/x/zapjournal/tests.lastJournalMessage(pid int, message string) (*Object, error)
Parser parses JSON.
Parser may be re-used for subsequent parsing.
Parser cannot be used from concurrent goroutines.
Use per-goroutine parsers or ParserPool instead.
b[]byteccache
Parse parses s containing JSON.
The returned value is valid until the next call to Parse*.
Use Scanner if a stream of JSON values must be parsed.
ParseBytes parses b containing JSON.
The returned Value is valid until the next call to Parse*.
Use Scanner if a stream of JSON values must be parsed.
func (*ParserPool).Get() *Parser
func (*ParserPool).Put(p *Parser)
ParserPool may be used for pooling Parsers for similarly typed JSONs.
poolsync.Pool
Get returns a Parser from pp.
The Parser must be Put to pp after use.
Put returns p to pp.
p and objects recursively returned from p cannot be used after p
is put into pp.
var handyPool
Scanner scans a series of JSON values. Values may be delimited by whitespace.
Scanner may parse JSON lines ( http://jsonlines.org/ ).
Scanner may be re-used for subsequent parsing.
Scanner cannot be used from concurrent goroutines.
Use Parser for parsing only a single JSON value.
b contains a working copy of json value passed to Init.
c is used for caching JSON values.
err contains the last error.
s points to the next JSON value to parse.
v contains the last parsed JSON value.
Error returns the last error.
Init initializes sc with the given s.
s may contain multiple JSON values, which may be delimited by whitespace.
InitBytes initializes sc with the given b.
b may contain multiple JSON values, which may be delimited by whitespace.
Next parses the next JSON value from s passed to Init.
Returns true on success. The parsed value is available via Value call.
Returns false either on error or on the end of s.
Call Error in order to determine the cause of the returned false.
Value returns the last parsed value.
The value is valid until the Next call.
Value represents any JSON value.
Call Type in order to determine the actual type of the JSON value.
Value cannot be used from concurrent goroutines.
Use per-goroutine parsers or ParserPool instead.
a[]*ValueoObjectsstringtType
Array returns the underlying JSON array for the v.
The returned array is valid until Parse is called on the Parser returned v.
Use GetArray if you don't need error handling.
Bool returns the underlying JSON bool for the v.
Use GetBool if you don't need error handling.
Del deletes the entry with the given key from array or object v.
Exists returns true if the field exists for the given keys path.
Array indexes may be represented as decimal numbers in keys.
Float64 returns the underlying JSON number for the v.
Use GetFloat64 if you don't need error handling.
Get returns value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
nil is returned for non-existing keys path.
The returned value is valid until Parse is called on the Parser returned v.
GetArray returns array value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
nil is returned for non-existing keys path or for invalid value type.
The returned array is valid until Parse is called on the Parser returned v.
GetBool returns bool value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
false is returned for non-existing keys path or for invalid value type.
GetFloat64 returns float64 value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
0 is returned for non-existing keys path or for invalid value type.
GetInt returns int value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
0 is returned for non-existing keys path or for invalid value type.
GetInt64 returns int64 value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
0 is returned for non-existing keys path or for invalid value type.
GetObject returns object value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
nil is returned for non-existing keys path or for invalid value type.
The returned object is valid until Parse is called on the Parser returned v.
GetStringBytes returns string value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
nil is returned for non-existing keys path or for invalid value type.
The returned string is valid until Parse is called on the Parser returned v.
GetUint returns uint value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
0 is returned for non-existing keys path or for invalid value type.
GetUint64 returns uint64 value by the given keys path.
Array indexes may be represented as decimal numbers in keys.
0 is returned for non-existing keys path or for invalid value type.
Int returns the underlying JSON int for the v.
Use GetInt if you don't need error handling.
Int64 returns the underlying JSON int64 for the v.
Use GetInt64 if you don't need error handling.
MarshalTo appends marshaled v to dst and returns the result.
Object returns the underlying JSON object for the v.
The returned object is valid until Parse is called on the Parser returned v.
Use GetObject if you don't need error handling.
Set sets (key, value) entry in the array or object v.
The value must be unchanged during v lifetime.
SetArrayItem sets the value in the array v at idx position.
The value must be unchanged during v lifetime.
String returns string representation of the v.
The function is for debugging purposes only. It isn't optimized for speed.
See MarshalTo instead.
Don't confuse this function with StringBytes, which must be called
for obtaining the underlying JSON string for the v.
StringBytes returns the underlying JSON string for the v.
The returned string is valid until Parse is called on the Parser returned v.
Use GetStringBytes if you don't need error handling.
Type returns the type of the v.
Uint returns the underlying JSON uint for the v.
Use GetInt if you don't need error handling.
Uint64 returns the underlying JSON uint64 for the v.
Use GetInt64 if you don't need error handling.
*Value : expvar.Var
*Value : fmt.Stringer
*Value : github.com/aws/smithy-go/middleware.stringer
*Value : context.stringer
*Value : runtime.stringer
func MustParse(s string) *Value
func MustParseBytes(b []byte) *Value
func Parse(s string) (*Value, error)
func ParseBytes(b []byte) (*Value, error)
func (*Arena).NewArray() *Value
func (*Arena).NewFalse() *Value
func (*Arena).NewNull() *Value
func (*Arena).NewNumberFloat64(f float64) *Value
func (*Arena).NewNumberInt(n int) *Value
func (*Arena).NewNumberString(s string) *Value
func (*Arena).NewObject() *Value
func (*Arena).NewString(s string) *Value
func (*Arena).NewStringBytes(b []byte) *Value
func (*Arena).NewTrue() *Value
func (*Object).Get(key string) *Value
func (*Parser).Parse(s string) (*Value, error)
func (*Parser).ParseBytes(b []byte) (*Value, error)
func (*Scanner).Value() *Value
func (*Value).Array() ([]*Value, error)
func (*Value).Get(keys ...string) *Value
func (*Value).GetArray(keys ...string) []*Value
func parseArray(s string, c *cache, depth int) (*Value, string, error)
func parseObject(s string, c *cache, depth int) (*Value, string, error)
func parseValue(s string, c *cache, depth int) (*Value, string, error)
func (*Object).Set(key string, value *Value)
func (*Value).Set(key string, value *Value)
func (*Value).SetArrayItem(idx int, value *Value)
var valueFalse *Value
var valueNull *Value
var valueTrue *Value
Package-Level Functions (total 32, in which 12 are exported)
Exists returns true if the field identified by keys path exists in JSON data.
Array indexes may be represented as decimal numbers in keys.
False is returned on error. Use Parser for proper error handling.
Parser is faster when multiple fields must be checked in the JSON.
GetBool returns boolean value for the field identified by keys path
in JSON data.
Array indexes may be represented as decimal numbers in keys.
False is returned on error. Use Parser for proper error handling.
Parser is faster for obtaining multiple fields from JSON.
GetBytes returns string value for the field identified by keys path
in JSON data.
Array indexes may be represented as decimal numbers in keys.
nil is returned on error. Use Parser for proper error handling.
Parser is faster for obtaining multiple fields from JSON.
GetFloat64 returns float64 value for the field identified by keys path
in JSON data.
Array indexes may be represented as decimal numbers in keys.
0 is returned on error. Use Parser for proper error handling.
Parser is faster for obtaining multiple fields from JSON.
GetInt returns int value for the field identified by keys path
in JSON data.
Array indexes may be represented as decimal numbers in keys.
0 is returned on error. Use Parser for proper error handling.
Parser is faster for obtaining multiple fields from JSON.
GetString returns string value for the field identified by keys path
in JSON data.
Array indexes may be represented as decimal numbers in keys.
An empty string is returned on error. Use Parser for proper error handling.
Parser is faster for obtaining multiple fields from JSON.
MustParse parses json string s.
The function panics if s cannot be parsed.
The function is slower than the Parser.Parse for re-used Parser.
MustParseBytes parses b containing json.
The function panics if b cannot be parsed.
The function is slower than the Parser.ParseBytes for re-used Parser.
Parse parses json string s.
The function is slower than the Parser.Parse for re-used Parser.
ParseBytes parses b containing json.
The function is slower than the Parser.ParseBytes for re-used Parser.