josephburnett / jd

JSON diff and patch
MIT License
1.86k stars 51 forks source link

support map[int]interface{} #13

Closed c625473164 closed 5 years ago

c625473164 commented 5 years ago

I have a map[int]interface{}, but I don't know if it is a good way to add this code to func NewJsonNode(n interface{}, options ...option) (JsonNode, error) {, or is there any way to transfrom it into a map[string]interaface{}

         case map[int]interface{}:
        m := make(jsonObject)
        for k, v := range t {
            if _, ok := v.(JsonNode); !ok {
                e, err := NewJsonNode(v, options...)
                if err != nil {
                    return nil, err
                }
                m[strconv.Itoa(k)] = e
            }
        }
        return m, nil
josephburnett commented 5 years ago

What is your use case? What data do you have that's a map with integer keys?