{"modulePath":"github.com/UnityTech/client-go","version":"v2.0.0+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package json\n\n## Variables\n\n```go\nvar DefaultMetaFactory = SimpleMetaFactory{}\n```\nDefaultMetaFactory is a default factory for versioning objects in JSON. The object in memory and in the default JSON serialization will use the \"kind\" and \"apiVersion\" fields.\n\n```go\nvar Framer = jsonFramer{}\n```\nFramer is the default JSON framing behavior, with newlines delimiting individual objects.\n\n```go\nvar YAMLFramer = yamlFramer{}\n```\nFramer is the default JSON framing behavior, with newlines delimiting individual objects.\n\n## Types\n\n```go\ntype MetaFactory interface {\n\t// Interpret should return the version and kind of the wire-format of\n\t// the object.\n\tInterpret(data []byte) (*unversioned.GroupVersionKind, error)\n}\n```\nMetaFactory is used to store and retrieve the version and kind information for JSON objects in a serializer.\n\n```go\ntype Serializer struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.ObjectTyper, pretty bool) *Serializer\n```\nNewSerializer creates a JSON serializer that handles encoding versioned objects into the proper JSON form. If typer is not nil, the object has the group, version, and kind fields set.\n\n```go\nfunc NewYAMLSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.ObjectTyper) *Serializer\n```\nNewYAMLSerializer creates a YAML serializer that handles encoding versioned objects into the proper YAML form. If typer is not nil, the object has the group, version, and kind fields set. This serializer supports only the subset of YAML that matches JSON, and will error if constructs are used that do not serialize to JSON.\n\n```go\nfunc (s *Serializer) Decode(originalData []byte, gvk *unversioned.GroupVersionKind, into runtime.Object) (runtime.Object, *unversioned.GroupVersionKind, error)\n```\nDecode attempts to convert the provided data into YAML or JSON, extract the stored schema kind, apply the provided default gvk, and then load that data into an object matching the desired schema kind or the provided into. If into is \\*runtime.Unknown, the raw data will be extracted and no decoding will be performed. If into is not registered with the typer, then the object will be straight decoded using normal JSON/YAML unmarshalling. If into is provided and the original data is not fully qualified with kind/version/group, the type of the into will be used to alter the returned gvk. On success or most errors, the method will return the calculated schema kind.\n\n```go\nfunc (s *Serializer) Encode(obj runtime.Object, w io.Writer) error\n```\nEncode serializes the provided object to the given writer.\n\n```go\nfunc (s *Serializer) RecognizesData(peek io.Reader) (ok, unknown bool, err error)\n```\nRecognizesData implements the RecognizingDecoder interface.\n\n```go\ntype SimpleMetaFactory struct {\n}\n```\nSimpleMetaFactory provides default methods for retrieving the type and version of objects that are identified with an \"apiVersion\" and \"kind\" fields in their JSON serialization. It may be parameterized with the names of the fields in memory, or an optional list of base structs to search for those fields in memory.\n\n```go\nfunc (SimpleMetaFactory) Interpret(data []byte) (*unversioned.GroupVersionKind, error)\n```\nInterpret will return the APIVersion and Kind of the JSON wire-format encoding of an object, or an error.\n\n","path":"github.com/UnityTech/client-go/pkg/runtime/serializer/json","name":"json","synopsis":"","isRedistributable":true}
