N
N
Nikita Shchypylov2017-04-13 12:01:34
JavaScript
Nikita Shchypylov, 2017-04-13 12:01:34

How to check if there are more objects in an object in JSON?

Hello everyone

, Here is my list of elements:

function getJson(file, template, container) {
  $.getJSON(file, function (data) {
})
}


And JSON:

{
  "item_1": {
    "img": "img/f.jpg",
    "article": "Glasses are cool",
    "price": "599"
  },
  "item_2": {
    "img": "img/g.jpg",
    "article": "Glasses are not so cool",
    "price": "699"
  },
  "item_3": {
    "img": "img/s.jpg",
    "article": "Glasses are beautiful",
    "price": "799"
  }
}


How to check, for example, if item_3 in price is not just a value, but an object? For example, like this:
{
  "item_3": {
    "img": "img/s.jpg",
    "article": "Glasses are beautiful",
    "price":  {
"value": "322",
"real":"yes"

}
  }
}


Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-04-13
@lebonnet

if (price && price.toString() === "[object Object]")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question