如何将值拆分为列

时间:2018-06-05 14:14:23

标签: json pentaho-data-integration

我有一个JSON文件,我会从中提取数据:

renderDistancesList() {
    if(_.isObject(this.state.distances)){
        let d = this.state.distances;
        console.log('this.state.distances ', d);
            return (
            <div>
                <h4>Distsances:</h4>
                {
                   this.getData(d)
                }
            </div>
            )
    } else {
  return (<div>Loading data...</div>)
}
}


  getData(d){
    return d.map((res,key)=>{
          return <li key={key}>{key}</li>
    })

想法是生成这样的数组:

&#13;
&#13;
{
"machineName": "Machine 1"
"SensorData": [
{
  "Sensor": {
    "Id": "19421238-2af4-41a4-819b-06c3e05067e7",
    "Alias": "T1"
  },
  "Values": {
    "0001-01-01T00:00:00": 20,
    "0001-01-01T00:00:01": 20,
    "0001-01-01T00:00:02": 21,
    "0001-01-01T00:00:03": 21

  }
},
{
  "Sensor": {
    "Id": "f22cc003-9edd-44d4-bb29-68f677b3b6c4",
    "Alias": "T2"
   },
  "Values": {
    "0001-01-01T00:00:00": 25,
    "0001-01-01T00:00:01": 25,
    "0001-01-01T00:00:02": 26,
    "0001-01-01T00:00:03": 27,
  }
},

...
&#13;
&#13;
&#13;

我可以提取每个传感器都有一条线的数据,但我不知道如何分割&#34;值&#34;为了获得两列:一列用于时间戳,一列用于时间戳....

0 个答案:

没有答案