Skip to content
Snippets Groups Projects
Commit e61cc9ce authored by Jano Hendriks's avatar Jano Hendriks
Browse files

#32 Handled nested arrays in arrays of objects

parent 6446b489
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ package audit
import (
"encoding/json"
"fmt"
"gitlab.com/uafrica/go-utils/errors"
"reflect"
"regexp"
......@@ -79,6 +80,11 @@ func GetChanges(original interface{}, new interface{}) (map[string]interface{},
index, _ := string_utils.StringToInt64(indexString)
field := ToSnakeCase(change.Path[2])
if len(change.Path) == 5 && string_utils.IsNumericString(change.Path[3]) {
// The field is actually an array of objects.
field += fmt.Sprintf("[%s] (%s)", change.Path[3], ToSnakeCase(change.Path[4]))
}
arrayObject, present := changes[objectKey]
if present {
if arrayOfObjects, ok := arrayObject.([]map[string]interface{}); ok {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment