Paste Go struct definitions and get an example JSON document built with the same rules encoding/json applies when marshaling: json:"..." tag names, fields hidden with -, the ,string option, unexported lowercase fields and flattened embedded structs.
It is handy for producing a curl body from a Gin, Echo or net/http request struct, preparing samples for gRPC-Gateway or REST docs, and spotting fields whose tags don't produce the key you expected.
type Xxx struct { ... } declarations. Grouped type ( ... ) blocks and several structs at once are fine.decimal.Decimal) become null.curl -d, a Postman body or an httptest-based handler test.type Base struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
}
type Job struct {
Base
Queue string `json:"queue"`
Attempts int `json:"attempts,string"`
Labels map[string]string `json:"labels,omitempty"`
TimeoutSec *int `json:"timeout_sec,omitempty"`
Token string `json:"-"`
Done bool
lastErr error
}{
"id": "",
"created_at": "0001-01-01T00:00:00Z",
"queue": "",
"attempts": "0",
"labels": {
"key": ""
},
"timeout_sec": 0,
"Done": false
}The embedded Base contributes id and created_at directly to Job, and Attempts, tagged with ,string, becomes the string "0" instead of a number. Token (tag -) and the unexported lastErr are dropped, while the untagged Done keeps its Go field name as the key. time.Time shows Go's zero value, 0001-01-01T00:00:00Z.
json:"name" tag as the key, falling back to the exact field name when there is no tag.json:"-" fields and unexported lowercase fields; json:"-," keeps the field under the literal key -.,string, numeric and boolean fields are wrapped as strings like "0" and "false".*int, *Profile) are filled with the pointed-to type, and defined types such as type Status string follow their underlying type.[]byte becomes a Base64 (empty) string, map[int]T uses a "0" key, time.Duration is the nanosecond integer 0, and interface{}/any are null.Children []Node stop at an empty array. Anonymous nested struct fields are supported.Paste the struct you bind with c.ShouldBindJSON(&req), generate the body, and call the endpoint through httptest.NewRequest or curl. Since keys come straight from the tags, binding mismatches are less likely.
Mixed json:"user_id" and json:"userId" tags, or a forgotten tag that leaks an upper-case UserID key, are obvious at a glance in the output.
Give frontend or Python consumers the JSON from your Go response struct; they can turn it back into models with tools like JSON → TypeScript or JSON → Python.
omitempty fields are always shown in the sample; real marshaling drops them when they hold the zero value.nil pointer marshals as null, but the sample shows the populated case.MarshalJSON() and the actual contents of json.RawMessage cannot be known and are not reflected.omitzero and encoding/json/v2 behavior are not covered.encoding/json uses the exported field name verbatim, so Done bool becomes "Done". Decoding in Go matches case-insensitively, but clients in other languages don't, so explicit tags are safer.
time.Time set to year 0001?Go's zero time.Time is 0001-01-01 00:00:00 UTC, which marshals in RFC 3339 as 0001-01-01T00:00:00Z. That's why it differs from the 1970 dates on the other → JSON pages.
json:",string" useful?Mostly for large int64 IDs that JavaScript can't represent exactly, so they travel as strings. The sample shows "0", making it clear to clients that they will receive a string.
Use the JSON → Go struct page. Feeding its output back into this page is a quick way to check that the round trip keeps the original keys.