MCPcopy Index your code
hub / github.com/keploy/keploy / LooksLikeJSON

Function LooksLikeJSON

pkg/util.go:3793–3800  ·  view source on GitHub ↗

LooksLikeJSON checks if a string appears to be JSON by checking for opening and closing brackets/braces. It trims whitespace and returns false for empty strings.

(s string)

Source from the content-addressed store, hash-verified

3791// LooksLikeJSON checks if a string appears to be JSON by checking for opening and closing brackets/braces.
3792// It trims whitespace and returns false for empty strings.
3793func LooksLikeJSON(s string) bool {
3794 s = strings.TrimSpace(s)
3795 if s == "" {
3796 return false
3797 }
3798 return (strings.HasPrefix(s, "{") && strings.Contains(s, "}")) ||
3799 (strings.HasPrefix(s, "[") && strings.Contains(s, "]"))
3800}
3801
3802// hasExplicitPort checks if the given host string (or host:port)
3803// has an explicit port defined. It handles IPv6 addresses (e.g. [::1]:8080) correctly.

Callers 2

normalizeNestedJSONValueFunction · 0.92
redactNodeFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected