Accessing the name of a JSON property in template node


#1

Hi folks,

I have an ESP8266 connected to a PZEM 004 sending messages with power readings...

Here is the structure of the JSON object:

object
Time: "2019-02-04T15:18:15"
ENERGY: object
TotalStartTime: "2019-02-03T09:46:57"
Total: 72.269
Yesterday: 15.613
Today: 56.656
Period: 24
Power: 2920
ApparentPower: 2939
ReactivePower: 336
Factor: 0.99
Voltage: 238
Current: 12.35

I am trying to display this data in a simple table, but I would like to do it without assuming the names of the various fields.... how can I do this? Something like this for example, which works in that I see the list of values, but I can't find a way to access the property names

<div layout="row" layout-align="start center">
  <span flex>Quantity</span>
  <span flex>Value</span>
</div>
<div layout="row" layout-align="start center" ng-repeat="ENERGY in msg.payload.ENERGY">
  <span flex style="color: green">{{ENERGY.name}}</span>
  <span flex style="color: red">{{ENERGY}}</span>
</div>

Can anyone help?


#2

It would help if you provide a valid JSON dataset for testing purposes. The JSON you posted is not valid and we can not guess what is the object that is nested in the property energy.