parser

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

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

func GetContainer(path string) (*gabs.Container, error)

GetContainer returns a gabs container from the given path.

func GetFirstString added in v0.5.6

func GetFirstString(v *gabs.Container, k ...string) string

GetFirstString returns the first non-empty string from the given keys.

func String added in v0.5.6

func String(v *gabs.Container, k ...string) string

func ToBool

func ToBool(v interface{}) bool

ToBool converts interface to bool. Hack to avoid panics when converting gabs data to string.

func ToFloat32

func ToFloat32(v interface{}) float32

func ToString

func ToString(v interface{}) string

ToString converts interface to string. Hack to avoid panics when converting gabs data to string.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL