This is a creation in Article, where the information may have evolved or changed.
Read the Kubernetes source code, read the Https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/extensions/types.go K8s type, when you encounter such a piece of code,
Represents a scaling request for a resource.type the scale struct {unversioned. Typemeta ' JSON: ", inline" '//Standard object metadata; More Info:http://releases.k8s.io/head/docs/devel/api-conventions.md#metadata.api.objectmeta ' JSON: ' metadata, Omitempty "//defines the behavior of the scale. More info:http://releases.k8s.io/head/docs/devel/api-conventions.md#spec-and-status. Spec scalespec ' json: ' spec,omitempty '//current status of the scale. More info:http://releases.k8s.io/head/docs/devel/api-conventions.md#spec-and-status. Read-only.status scalestatus ' JSON: "Status,omitempty" '}
And then the back of the "inside of the JSON string, I don't understand
This is the structtag of the Go language.
What's 1 for?
If you want to manually configure the corresponding relationship between the members of the struct and the JSON field, you can label the members when you define the structure body:
With Omitempty, if the field is nil or 0 values (the number 0, the string "", the empty array [], and so on), then the wrapped JSON result will not have this fields.
2 How to use AH? http://blog.csdn.net/tiaotiaoyly/article/details/38942311 Click to open link
Type Message struct {Name string ' JSON: ' msg_name '///Msg_namebody string ' JSON for JSON: ' body,omitempty '///if empty, ignore Field time Int64 ' JSON: "-" '///Direct Ignore field}var m = message{name: "Alice", Body: ", Time:1294706395881547000,}data, er r: = json. Marshal (m) if err! = Nil {fmt. Printf (Err. Error ()) return}fmt. PRINTLN (String data) output:{"Msg_name": "Alice"}