Skip to content

Commit

Permalink
add comments to CreateMergePatch
Browse files Browse the repository at this point in the history
Signed-off-by: Curtis La Graff <[email protected]>
  • Loading branch information
clagraff committed Mar 21, 2018
1 parent 05e46dc commit ce89457
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,17 @@ func CreateMergePatch(originalJSON, modifiedJSON []byte) ([]byte, error) {
originalResemblesArray := resemblesJSONArray(originalJSON)
modifiedResemblesArray := resemblesJSONArray(modifiedJSON)

// Do both byte-slices seem like JSON arrays?
if originalResemblesArray && modifiedResemblesArray {
return createArrayMergePatch(originalJSON, modifiedJSON)
}

// Are both byte-slices are not arrays? Then they are likely JSON objects...
if !originalResemblesArray && !modifiedResemblesArray {
return createObjectMergePatch(originalJSON, modifiedJSON)
}

// None of the above? Then return an error because of mismatched types.
return nil, errBadMergeTypes
}

Expand Down

0 comments on commit ce89457

Please sign in to comment.