jsonhelper

package
v0.0.0-...-6c4fd92 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: NIST-PD-fallback Imports: 4 Imported by: 0

Documentation

Overview

Package jsonhelper provides JSON-related helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanCgoStruct

func CleanCgoStruct(input any) any

CleanCgoStruct cleans roundtripped object from a cgo-generated structure. It deletes padding and reserved fields, then converts object keys to lowerCamalCase.

func Roundtrip

func Roundtrip(input, ptr any, options ...Option) error

Roundtrip marshals the input to JSON then unmarshals it into ptr. This is useful for converting between structures.

Types

type Option

type Option func(*json.Decoder)

Option sets an option on json.Decoder.

var DisallowUnknownFields Option = func(d *json.Decoder) { d.DisallowUnknownFields() }

DisallowUnknownFields causes json.Decoder to reject unknown struct fields.

Jump to

Keyboard shortcuts

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