{"modulePath":"github.com/devdraftengineer/devdraft-go","version":"v0.0.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package apijson\n\n## Variables\n\n```go\nvar EscapeSJSONKey = strings.NewReplacer(\"\\\\\", \"\\\\\\\\\", \"|\", \"\\\\|\", \"#\", \"\\\\#\", \"@\", \"\\\\@\", \"*\", \"\\\\*\", \".\", \"\\\\.\", \":\", \"\\\\:\", \"?\", \"\\\\?\").Replace\n```\nIf we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have special characters that sjson interprets as a path.\n\n## Functions\n\n```go\nfunc Marshal(value any) ([]byte, error)\n```\n\n```go\nfunc MarshalRoot(value any) ([]byte, error)\n```\n\n```go\nfunc Port(from any, to any) error\n```\nPort copies over values from one struct to another struct.\n\n```go\nfunc RegisterDiscriminatedUnion[T any](key string, mappings map[string]reflect.Type)\n```\n\n```go\nfunc RegisterFieldValidator[T any, V string | bool | int](fieldName string, values ...V)\n```\n\n```go\nfunc RegisterUnion[T any](discriminator string, variants ...UnionVariant)\n```\n\n```go\nfunc Unmarshal(raw []byte, to any) error\n```\nUnmarshal is similar to [encoding/json.Unmarshal](/encoding/json#Unmarshal) and parses the JSON-encoded data and stores it in the given pointer.\n\n```go\nfunc UnmarshalRoot(raw []byte, to any) error\n```\nUnmarshalRoot is like Unmarshal, but doesn't try to call MarshalJSON on the root element. Useful if a struct's UnmarshalJSON is overrode to use the behavior of this encoder versus the standard library.\n\n## Types\n\n```go\ntype Field struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (j Field) IsInvalid() bool\n```\n\n```go\nfunc (j Field) IsMissing() bool\n```\n\n```go\nfunc (j Field) IsNull() bool\n```\nReturns true if the field is explicitly \\`null\\` \\_or\\_ if it is not present at all (ie, missing). To check if the field's key is present in the JSON with an explicit null value, you must check \\`f.IsNull() \u0026\u0026 !f.IsMissing()\\`.\n\n```go\nfunc (j Field) Raw() string\n```\n\n```go\ntype UnionUnmarshaler[T any] struct {\n\tValue T\n}\n```\nUseful to wrap a union type to force it to use [apijson.UnmarshalJSON](#UnmarshalJSON) since you cannot define an UnmarshalJSON function on the interface itself.\n\n```go\nfunc (c *UnionUnmarshaler[T]) UnmarshalJSON(buf []byte) error\n```\n\n```go\ntype UnionVariant struct {\n\tTypeFilter         gjson.Type\n\tDiscriminatorValue any\n\tType               reflect.Type\n}\n```\n\n```go\nfunc Discriminator[T any](value any) UnionVariant\n```\n\n","path":"github.com/devdraftengineer/devdraft-go/internal/apijson","name":"apijson","synopsis":"","isRedistributable":true}
