JSONBodyIfLikely escapes JSON bodies when the content type or body shape indicates JSON.
(body []byte, contentType string)
| 52 | |
| 53 | // JSONBodyIfLikely escapes JSON bodies when the content type or body shape indicates JSON. |
| 54 | func JSONBodyIfLikely(body []byte, contentType string) ([]byte, bool) { |
| 55 | if IsJSONContentType(contentType) || LooksLikeJSON(body) { |
| 56 | return JSONBody(body) |
| 57 | } |
| 58 | return body, false |
| 59 | } |
| 60 | |
| 61 | // JSONValue recursively escapes string values in JSON-compatible data. |
| 62 | func JSONValue(value any) any { |