(parent, child []fastJsonNode)
| 884 | } |
| 885 | |
| 886 | func (enc *encoder) merge(parent, child []fastJsonNode) ([]fastJsonNode, error) { |
| 887 | if len(parent) == 0 { |
| 888 | return child, nil |
| 889 | } |
| 890 | |
| 891 | // Here we merge two slices of maps. |
| 892 | mergedList := make([]fastJsonNode, 0) |
| 893 | cnt := 0 |
| 894 | for _, pa := range parent { |
| 895 | for _, ca := range child { |
| 896 | paCopy, paNodeCount := enc.copyFastJsonList(pa) |
| 897 | caCopy, caNodeCount := enc.copyFastJsonList(ca) |
| 898 | |
| 899 | cnt += paNodeCount + caNodeCount |
| 900 | if cnt > x.Config.LimitNormalizeNode { |
| 901 | return nil, errors.Errorf( |
| 902 | "Couldn't evaluate @normalize directive - too many results") |
| 903 | } |
| 904 | |
| 905 | if paCopy == nil { |
| 906 | paCopy = caCopy |
| 907 | } else { |
| 908 | temp := paCopy |
| 909 | for temp.next != nil { |
| 910 | temp = temp.next |
| 911 | } |
| 912 | temp.next = caCopy |
| 913 | } |
| 914 | mergedList = append(mergedList, paCopy) |
| 915 | } |
| 916 | } |
| 917 | return mergedList, nil |
| 918 | } |
| 919 | |
| 920 | // normalize returns all attributes of fj and its children (if any). |
| 921 | func (enc *encoder) normalize(fj fastJsonNode) ([]fastJsonNode, error) { |
no test coverage detected