Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrJsonDecode = errors.New("failed to decode json")
ErrJsonDecode is the error returned when JSON decoding fails.
Functions ¶
This section is empty.
Types ¶
type JsonDifference ¶
type JsonDifference struct {
// contains filtered or unexported fields
}
JsonDifference represents the difference between two JSON structures.
func BetweenJson ¶
func BetweenJson(expected, received io.Reader) (*JsonDifference, error)
BetweenJson compares two JSON inputs and returns their difference.
Parameters:
- expected: io.Reader containing the expected JSON data
- received: io.Reader containing the received JSON data
Returns:
- *JsonDifference: A pointer to a JsonDifference struct containing the differences
- error: An error if there was a problem decoding the JSON inputs
The function reads JSON data from both inputs, compares them, and generates a difference map.
func (*JsonDifference) GenerateReport ¶
func (jd *JsonDifference) GenerateReport() string
GenerateReport creates a human-readable string report of the differences.
Returns:
- string: A formatted string showing the differences between the expected and received JSON
The report uses color coding and indentation to clearly display the differences:
- Red lines (prefixed with '-') indicate expected values
- Green lines (prefixed with '+') indicate received values
func (*JsonDifference) HasDifferences ¶
func (jd *JsonDifference) HasDifferences() bool
HasDifferences checks if there are any differences between the compared JSON structures.
Returns:
- bool: true if differences exist, false otherwise
Click to show internal directories.
Click to hide internal directories.