internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractJSONKeys

func ExtractJSONKeys(r io.Reader) ([]string, error)

ExtractJSONKeys extracts the top-level keys from a JSON object provided by an io.Reader.

It expects the input to be a valid JSON object (i.e., starting with '{'). The function iterates through all key-value pairs at the top level, collects the keys in the order they appear in the JSON string, and skips the values.

Parameters:

  • r: an io.Reader containing the JSON object.

Returns:

  • []string: a slice of strings containing the keys found at the top level of the JSON object, in the same order as in the input JSON.
  • error: an error if the input is not a valid JSON object or if any decoding issues occur.

func FetchJSON

func FetchJSON[T any](url string, value *T) error

FetchJSON fetches JSON data from the given URL and decodes it into the provided variable.

Parameters:

  • url: the URL to fetch the JSON from.
  • value: a pointer to the variable where the decoded JSON will be stored.

Returns:

  • error: an error if the HTTP request fails or the JSON cannot be decoded.

Types

This section is empty.

Jump to

Keyboard shortcuts

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