json

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceJSONPlaceholders

func ReplaceJSONPlaceholders(source string, jsonData string) string

func StringifyJSON

func StringifyJSON(data interface{}) (string, error)

func UnmashalJSONResponse

func UnmashalJSONResponse(resp *http.Response, v interface{}, b *[]byte) error

UnmashalJSONResponse unmarshalls a generic HTTP response body into a JSON structure Pass optionally a pointer to a byte array to get the raw body of the response object written back

Types

type JSONProperty

type JSONProperty struct {
	Name  string
	Value JSONValue
}

JSONProperty represents a name-value pair for a JSON property where the value can be a static value or a pattern for a value fetched dynamically from the authorization JSON

type JSONValue

type JSONValue struct {
	// Static value of the JSON property.
	Static interface{}
	// Resolves the value of the JSON property by fetching the pattern from the authorization JSON.
	Pattern string
}

func (*JSONValue) IsTemplate

func (v *JSONValue) IsTemplate() bool

IsTemplate tells whether a pattern is as a simple pattern or a template that mixes static value with variable placeholders that resolve to patterns. In case of a template that mixes no variable placeholder, but it contains nothing but a static string value, users should use `JSONValue.Static` instead of `JSONValue.Pattern`.

func (*JSONValue) ResolveFor

func (v *JSONValue) ResolveFor(jsonData string) interface{}

ResolveFor resolves a value for a given input JSON. For static values, it returns the value right away; for patterns, it magically decides whether to process as a simple pattern or as a template that mixes static value with variable placeholders that resolve to patterns. In case of a template that mixes no variable placeholder, but it contains nothing but a static string value, users should use `JSONValue.Static` instead of `JSONValue.Pattern`.

Jump to

Keyboard shortcuts

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