Documentation
¶
Overview ¶
Package parser provides JSON parsing utilities for scanner output.
Built on gabs for flexible JSON traversal, the package provides type-safe extraction functions:
- ToString: safely extract string values
- ToFloat32: safely extract float32 values
- ToBool: safely extract boolean values
- Children: safely iterate over array elements
These functions handle missing or malformed data gracefully, returning zero values rather than panicking.
Example usage:
container, _ := gabs.ParseJSON(data)
name := parser.ToString(container.Search("package", "name").Data())
score := parser.ToFloat32(container.Search("cvss", "score").Data())
Index ¶
- func FirstNonEmpty(v ...interface{}) string
- func GetContainer(path string) (*gabs.Container, error)
- func GetFirstString(v *gabs.Container, k ...string) string
- func String(v *gabs.Container, k ...string) string
- func ToBool(v interface{}) bool
- func ToFloat32(v interface{}) float32
- func ToString(v interface{}) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstNonEmpty ¶ added in v0.5.6
func FirstNonEmpty(v ...interface{}) string
func GetContainer ¶
GetContainer returns a gabs container from the given path.
func GetFirstString ¶ added in v0.5.6
GetFirstString returns the first non-empty string from the given keys.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.