MCPcopy Create free account
hub / github.com/dolthub/doltgresql / UnmarshalAndMarshalJsonString

Function UnmarshalAndMarshalJsonString

testing/go/framework.go:644–655  ·  view source on GitHub ↗

UnmarshalAndMarshalJsonString is used to normalize expected json type value to compare the actual value. JSON type value is in string format, and since Postrges JSON type preserves the input string if valid, it cannot be compared to the returned map as json.Marshal method space padded key value pair

(val string)

Source from the content-addressed store, hash-verified

642// To allow result matching, we unmarshal and marshal the expected string. This causes missing check
643// for the identical format as the input of the json string.
644func UnmarshalAndMarshalJsonString(val string) string {
645 var decoded any
646 err := json.Unmarshal([]byte(val), &decoded)
647 if err != nil {
648 panic(err)
649 }
650 ret, err := json.Marshal(decoded)
651 if err != nil {
652 panic(err)
653 }
654 return string(ret)
655}
656
657// NormalizeValToString normalizes values into types that can be compared.
658// JSON types, any pg types and time and decimal type values are converted into string value.

Callers 1

NormalizeExpectedRowFunction · 0.85

Calls 2

UnmarshalMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected