path

package
v1.0.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToJSON

func ToJSON(valor interface{}) ([]byte, error)

ToJSON converte o valor extraído de volta para JSON

func ToJSONIndent

func ToJSONIndent(valor interface{}) ([]byte, error)

ToJSONIndent converte o valor extraído para JSON formatado

Types

type Extrator

type Extrator struct {
	// contains filtered or unexported fields
}

Extrator é responsável por extrair valores de estruturas JSON usando JSONPath

func NovoExtrator

func NovoExtrator(jsonBytes []byte) (*Extrator, error)

NovoExtrator cria uma nova instância do extrator a partir de bytes JSON

func NovoExtrotorFromMap

func NovoExtrotorFromMap(data map[string]interface{}) *Extrator

NovoExtrotorFromMap cria uma nova instância do extrator a partir de um map

func (*Extrator) Existe

func (e *Extrator) Existe(caminho string) bool

Existe verifica se um caminho existe no JSON

func (*Extrator) Extrair

func (e *Extrator) Extrair(caminho string) (interface{}, error)

Extrair extrai um valor do JSON usando um caminho no formato JSONPath Exemplos de caminhos válidos:

  • "nome" -> retorna valor direto
  • "dados_profissionais" -> retorna objeto completo
  • "dados_profissionais.empregador" -> navega em objetos aninhados
  • "cursos" -> retorna array completo
  • "cursos[0]" -> retorna primeiro elemento do array
  • "cursos[1].nome" -> retorna campo de um elemento do array

func (*Extrator) ExtrairArray

func (e *Extrator) ExtrairArray(caminho string) ([]interface{}, error)

ExtrairArray é um helper que extrai e retorna um slice

func (*Extrator) ExtrairBool

func (e *Extrator) ExtrairBool(caminho string) (bool, error)

ExtrairBool é um helper que extrai e converte para bool

func (*Extrator) ExtrairFloat

func (e *Extrator) ExtrairFloat(caminho string) (float64, error)

ExtrairFloat é um helper que extrai e converte para float64

func (*Extrator) ExtrairInt

func (e *Extrator) ExtrairInt(caminho string) (int, error)

ExtrairInt é um helper que extrai e converte para int

func (*Extrator) ExtrairMultiplos

func (e *Extrator) ExtrairMultiplos(caminhos ...string) (map[string]interface{}, error)

ExtrairMultiplos extrai múltiplos caminhos de uma só vez

func (*Extrator) ExtrairObjeto

func (e *Extrator) ExtrairObjeto(caminho string) (map[string]interface{}, error)

ExtrairObjeto é um helper que extrai e retorna um map

func (*Extrator) ExtrairString

func (e *Extrator) ExtrairString(caminho string) (string, error)

ExtrairString é um helper que extrai e converte para string

Jump to

Keyboard shortcuts

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