1
{
                  "providerProperties": [
                    {
                      "key": "hotelnum",
                      "value": "123"
                    },
                    {
                      "key": "contract",
                      "value": "ABC"
                    },
                    {
                      "key": "Sequence",
                      "value": "1213"
                    },
                    {
                      "key": "lastFourDigit",
                      "value": "5454"
                    },
                    {
                      "key": "shop",
                      "value": "abc"
                    },
                    {
                      "key": "bookingEmailAddress",
                      "value": "abc@gmail.COM"
                    },
                    {
                      "key": "numOfRooms",
                      "value": "1"
                    }
}

Backbone/chaplinJS : How to check for key existence in object. for example want to check of key "numOfRooms" is available or not.

Ravi Ubana
  • 397
  • 5
  • 26

1 Answers1

4

You can use underscore method findWhere like _.findWhere(yourObject.providerProperties, {key: "numOfRooms"}); if the result is not undefined then it is present

T J
  • 42,762
  • 13
  • 83
  • 138