I am working with data being pulled from a MySQL database. One of my fields is JSON. The JSON data consists of four fields and is a variable number of records. The field is a list of characteristics of hard drives and is in the following format: [{"crushed": "Yes", "diskmfg": "IBM", "degaussed": "Yes", "diskserial": "erweq55645645"}] If there is more than 1 disk recorded in the database: [{"crushed": "Yes", "diskmfg": "IBM", "degaussed": "Yes", "diskserial": "erweq55645645"}, {"crushed": "Yes", "diskmfg": "IBM", "degaussed": "Yes", "diskserial": "asdfsdfsdfsadf"}, {"crushed": "No", "diskmfg": "Seagate", "degaussed": "No", "diskserial": "sdfasdfasdfsdfsd"}, {"crushed": "Yes", "diskmfg": "Seagate", "degaussed": "Yes", "diskserial": "asdfsdfsdfewwww"}] I read a previous post regarding processing of JSON data and saw the suggestion to use the Map function. I entered the following code in my build php, but am unsure of how to make the data appear in the view php. Also, how do I handle determining how many records are contained in the JSON data since it will be variable? Code in my build.php is below:
$this->src('servers')
      ->query("SELECT * FROM Decom where equiptype=\"Server\"")
       ->pipe(new Map([
        "{test}"=> function($row) {
           $jsonData = $row["drives"];
           $jsonData = json_decode($jsonData, true);
           $row["crushed"] = $jsonData["crushed"];
           $row["diskmfg"] = $jsonData["diskmfg"];
           $row["degaussed"] = $jsonData["degaussed"];
           $row["diskserial"] = $jsonData["diskserial"];
        return $row;
        }
      ]))
      ->pipe($this->dataStore('server_data'));