Hi,

I have an array of JSON objects as

Structs:
```
type Data struct {
    TaiList []Tai `json:"taiList"`
}

type Tai struct {
    PlmnId *PlmnId `json:"plmnId"`

    Tac string `json:"tac"`

    Nid string `json:"nid"`
}

type PlmnId struct {
    Mcc string `json:"mcc"`

    Mnc string `json:"mnc"`
}
```

The JSON is of the form

```
{
    "taiList": [
      {
        "plmnId": {
            "mcc": "244",
            "mnc": "24"
        },
        "tac": "00001",
        "nid": "99"
        },
        {
        "plmnId": {
            "mcc": "244",
            "mnc": "34"
        },
        "tac": "00001",
        "nid": "555"
        }
    ]
}
``` 

I would like to check if the JSON object "ta" is contain in the "taiList".

```
 var ta = model.Tai{
    PlmnId: &model.PlmnId{Mcc: "244", Mnc: "34"},
    Tac:    "00001",
    Nid:    "555",
}
```


I tried with the code below

```
func CheckTai(tai model.Tai, TaiList []model.Tai) bool {
    for _, Tai := range TaiList {
        if reflect.DeepEqual(Tai, tai) {
            return true
        }
    }
    return false
}

```

but CheckTai function return false. 
The CheckTai only return true when there is only one JSON object that match 
the list as

```
{
      "taiList": [
        {
          "plmnId": {
            "mcc": "244",
            "mnc": "24"
          },
          "tac": "00001",
          "nid": "555"
        }

      ]
    }
```

Need help or idea on how to perform this check.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0ce8cf94-cf99-4a84-83d5-ea176973d0bcn%40googlegroups.com.

Reply via email to