Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StructToJson ¶
A convenience function for printing an arbitrary struct as a JSON blob with/without indent, prefix, and dynamically ignored keys. Particularly useful when dealing with user-generated or otherwise dynamic/unpredictable structures.
Types ¶
type Option ¶
type Option func(settings *Settings)
Options are functions you can pass to StructToJson to apply the settings dynamically
func WithIgnore ¶
Adds one or more dotpaths (or top-level keys) to be ignored when calling StructToJson
func WithIndent ¶
Sets the Indent string when calling StructToJson
func WithPrefix ¶
Sets the Prefix string when calling StructToJson
type Settings ¶
type Settings struct { // If specified, prefixes each line after the first with the value Prefix string // If specified, the JSON will be rendered indented, repeating this value once for each level of indent Indent string // A list of fields to ignore. You can specify dotpath notation, like "foo.bar" Ignore []string }
Configuration for how a given object should be converted to JSON
Click to show internal directories.
Click to hide internal directories.