extractor

package
v1.52.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Copyright 2025 SGNL.ai, Inc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttributesFromJSONPath

func AttributesFromJSONPath(expression string) (result []string, err error)

AttributesFromJSONPath extracts a list of all valid attribute names from a JSON path expression based on the spec outlined in the article https://goessner.net/articles/JsonPath/, which github.com/PaesslerAG/jsonpath implements.

This function ignores all Union operators, Slice operators, Subscript operators, Wildcards, Filter expressions, and Script expressions. For example, for a provided expression of `$.book[?(@.price<10)].authors[1]`, this function would return `[]string{"book", "authors"}`. Recursive descents will also be ignored and instead treated as a direct descent.

All provided expressions must start with a `$.` prefix.

func ValueFromList

func ValueFromList(values []string, includedPrefix, excludedSuffix string) string

ValueFromList attempts to extract a value from the provided list based on the provided includedPrefix and excludedSuffix.

For example, if you want to extract a URL from a header with the following format: `<https://test-instance.oktapreview.com/api/v1/users?after=100u65xtp32NovHoPx1d7&limit=2>; rel="next"`

You could specify a `includedPrefix` of `https://` and an `excludedSuffix` of `>; rel="next"`. This would return the first value found matching this pattern in the following format: `https://test-instance.oktapreview.com/api/v1/users?after=100u65xtp32NovHoPx1d7&limit=2`.

All whitespace is ignored in values, prefixes, and suffixes. If there are multiple matching values provided, the value from the first matched will be returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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