Skip to content

Commit

Permalink
Docs: Mention JSONSerialer with ToJSON/BodyJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
earthboundkid committed Oct 6, 2023
1 parent 219bc7a commit 4010c30
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions body.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func BodySerializer(s Serializer, v any) BodyGetter {
}

// BodyJSON is a BodyGetter that marshals a JSON object.
//
// It uses [JSONSerializer] to marshal the object.
func BodyJSON(v any) BodyGetter {
return BodySerializer(JSONSerializer, v)
}
Expand Down
3 changes: 3 additions & 0 deletions builder_extras.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func (rb *Builder) BodySerializer(s Serializer, v any) *Builder {
}

// BodyJSON sets the Builder's request body to the marshaled JSON.
// It uses [JSONSerializer] to marshal the object.
// It also sets ContentType to "application/json".
func (rb *Builder) BodyJSON(v any) *Builder {
return rb.
Expand Down Expand Up @@ -180,6 +181,8 @@ func (rb *Builder) ToDeserializer(d Deserializer, v any) *Builder {
}

// ToJSON sets the Builder to decode a response as a JSON object
//
// It uses [JSONDeserializer] to unmarshal the object.
func (rb *Builder) ToJSON(v any) *Builder {
return rb.Handle(ToJSON(v))
}
Expand Down
2 changes: 2 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func ToDeserializer(d Deserializer, v any) ResponseHandler {
}

// ToJSON decodes a response as a JSON object.
//
// It uses [JSONDeserializer] to unmarshal the object.
func ToJSON(v any) ResponseHandler {
return ToDeserializer(JSONDeserializer, v)
}
Expand Down

0 comments on commit 4010c30

Please sign in to comment.