Getting specific property of a JSON object

Asked

Viewed 72 times

1

I have the following JSON:

 {
  "2016": {
    "mes": {
      "2": {
        "dia": {
          "5": {
            "-KcENENmSJcZp56clzz5": {
              "descricao": "teste",
              "valor": "99"
            }
          }
        }
      }
    }
  },
  "2017": {
    "mes": {
      "2": {
        "dia": {
          "5": {
            "-KcELskoSWWttptIgb0L": {
              "descricao": "xx",
              "valor": "55"
            }
          }
        }
      }
    }
  },
  "$id": "ano",
  "$priority": null
}

This is a firebase return, I would like to take for example the value 2016.

I use angular to popular a list like this:

<li ng-repeat="gasto in gastos"> 

</li>

If inside my tag li me use {{gasto.$id}} prints "ano" and I don’t know how to take the value 2016 for example.

  • 1

    if you do {{ spend['2016'] }} it will return the json: "mes": { "2": { "day": { "5": { "-Kcenenmsjczp56clzz5": { "Description": "test", "value": "99" } } } } }

  • @Juniornunes is that same brother, publish the answer for me to mark for you

1 answer

3


You’ll get it like this:

{{ gasto['2016'] }}

Upshot:

"mes": {
  "2": {
    "dia": {
      "5": {
        "-KcENENmSJcZp56clzz5": {
          "descricao": "teste",
          "valor": "99"
        }
      }
    }
  }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.