{"modulePath":"github.com/devdraftengineer/devdraft-go","version":"v0.0.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package respjson\n\n## Constants\n\n```go\nconst Null string = \"null\"\n```\n\n```go\nconst Omitted string = \"\"\n```\n\n## Types\n\n```go\ntype Field struct {\n\t// contains filtered or unexported fields\n}\n```\nA Field provides metadata to indicate the presence of a value.\n\nUse [Field.Valid](#Field.Valid) to check if an optional value was null or omitted.\n\nA Field will always occur in the following structure, where it mirrors the original field in its parent struct:\n\n\ttype ExampleObject struct {\n\t\tFoo bool\t`json:\"foo\"`\n\t\tBar int\t\t`json:\"bar\"`\n\t\t// ...\n\n\t\t// JSON provides metadata about the object.\n\t\tJSON struct {\n\t\t\tFoo Field\n\t\t\tBar Field\n\t\t\t// ...\n\t\t} `json:\"-\"`\n\t}\n\nTo differentiate a \"nullish\" value from the zero value, use the [Field.Valid](#Field.Valid) method.\n\n\tif !example.JSON.Foo.Valid() {\n\t\tprintln(\"Foo is null or omitted\")\n\t}\n\n\tif example.Foo {\n\t\tprintln(\"Foo is true\")\n\t} else {\n\t\tprintln(\"Foo is false\")\n\t}\n\nTo differentiate if a field was omitted or the JSON value \"null\", use the [Field.Raw](#Field.Raw) method.\n\n\tif example.JSON.Foo.Raw() == \"null\" {\n\t\tprintln(\"Foo is null\")\n\t}\n\n\tif example.JSON.Foo.Raw() == \"\" {\n\t\tprintln(\"Foo was omitted\")\n\t}\n\nOtherwise, if the field was invalid and couldn't be marshalled successfully, [Field.Valid](#Field.Valid) will be false and [Field.Raw](#Field.Raw) will not be empty.\n\n```go\nfunc NewField(raw string) Field\n```\n\n```go\nfunc NewInvalidField(raw string) Field\n```\n\n```go\nfunc (j Field) Raw() string\n```\nReturns the raw JSON value of the field.\n\n```go\nfunc (j Field) Valid() bool\n```\nValid returns true if the parent field was set. Valid returns false if the value doesn't exist, is JSON null, or is an unexpected type.\n\n","path":"github.com/devdraftengineer/devdraft-go/packages/respjson","name":"respjson","synopsis":"","isRedistributable":true}
