Converts pie chart data to the pie chart Flot data format; expects a single array of key/value pairs

@param array $data the data to convert
@return json array of series data with labels and data; empty if no data or trying to convert multiple series
334462
public function convertToPie(array $data)
    {
        // make sure not trying to convert data that contains multiple series
        if ($this->hasMultipleSeries($data)) {
            return json_encode(array());
        }

        $chartData = array();

        foreach ($data as $label => $data) {
            $chartData[] = array('label' => $label, 'data' => $data);
        }

        return json_encode($chartData);
    }
872221
protected function _getData(array $data): array
    {
        // Stringify empty values
        if (!empty($data)) {
            foreach ($data as $fieldName => $value) {
                $data[$fieldName] = $this->_stringifyEmptyValue($value);
            }
        }

        return $data;
    }
122619
private function unserializeArray(array $data)
    {
        $unserialized = [];

        foreach ($data as $key => $value) {
            if ($value instanceof ObjectStub) {
                $unserialized[$key] = $value->getObject();

                continue;
            }

            $unserialized[$key] = is_array($value) ? $this->unserializeArray($value) : $value;
        }

        return $unserialized;
    }
1239851
public function arraySerialize(array $Data)
    {
        $Result = "";
        foreach ($Data as $Value) {
            if ($Result == "") {
                $Result = floor($Value);
            } else {
                $Result = $Result . "," . floor($Value);
            }
        }

        return $Result;
    }
759975
public function convertTypeChildren(array $data = null)
    {
        if (empty($data)) {
            return null;
        }

        $result = new TypeDefinitionList();
        $types = [];

        $typesList = $data[JSONConstants::JSON_TYPESLIST_TYPES] ?? [];

        foreach (array_filter($typesList, 'is_array') as $typeData) {
            $type = $this->convertTypeDefinition($typeData);
            if ($type !== null) {
                $types[] = $type;
            }
        }

        $result->setList($types);
        $result->setHasMoreItems((boolean) ($data[JSONConstants::JSON_TYPESLIST_HAS_MORE_ITEMS] ?? false));
        $result->setNumItems($data[JSONConstants::JSON_TYPESLIST_NUM_ITEMS] ?? 0);
        $result->setExtensions($this->convertExtension($data, JSONConstants::getTypesListKeys()));

        return $result;
    }
330315
public function convert( $data ) {
		if ( is_object($data) ) {
			$data = Helper::convert_wp_object($data);
		} else if ( is_array($data) ) {
			$func = __FUNCTION__;
			foreach ( $data as &$ele ) {
				if ( is_array($ele) ) {
					$ele = $this->$func($ele);
				} else if ( is_object($ele) ) {
					$ele = Helper::convert_wp_object($ele);
				}
			}
		}
		return $data;
	}
600980
protected function jsonEncode(array $data)
    {
        set_error_handler(function () {
            $this->handleJsonError(JSON_ERROR_SYNTAX);
        }, E_WARNING);
        
        $json = json_encode($data, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
        restore_error_handler();
        $this->handleJsonError(json_last_error());
        
        return $json;
    }
830840
public static function jsonEncode($data)
    {
        $json = json_encode($data);
        // if json_encode failed
        if ($json === false) {
            self::jsonLastError();
        }
        return $json;
    }
458376
public function convert(array $data)
    {
        if (empty($data['code'])) {
            if (empty($data['ctcp'])) {
                $event = new UserEvent;
            } else {
                $event = new CtcpEvent;
                $event->setCtcpCommand($data['ctcp']['command']);
                if (!empty($data['ctcp']['params'])) {
                    $event->setCtcpParams($data['ctcp']['params']);
                }
            }
            if (!empty($data['prefix'])) {
                $event->setPrefix($data['prefix']);
            }
            if (!empty($data['nick'])) {
                $event->setNick($data['nick']);
            }
            if (!empty($data['user'])) {
                $event->setUsername($data['user']);
            }
            if (!empty($data['host'])) {
                $event->setHost($data['host']);
            }
            if (!empty($data['targets'])) {
               $event->setTargets($data['targets']);
            }
        } else {
            $event = new ServerEvent;
            $event->setServername($data['servername']);
            $event->setCode($data['code']);
        }
        $event->setMessage($data['message']);
        if (isset($data['params'])) {
            if (isset($data['params']['all'])) {
                unset($data['params']['all']);
            }
            $event->setParams($data['params']);
        }
        $event->setCommand($data['command']);
        return $event;
    }
1073650
protected function _format(array $data) {
		foreach (['id', 'rev'] as $key) {
			if (isset($data["_{$key}"])) {
				$data[$key] = $data["_{$key}"];
				unset($data["_{$key}"]);
			}
		}
		return $data;
	}
545778
static public function encode($data)
	{
	    if (is_string($data)) {
	        $data = str_replace(array("\r\n"), "", $data);
	        if (strpos($data, '{') ===0 || strpos($data, '[') ===0) {
	            $data = json_decode($data, true);
	        }
	    }
	    
		return json_encode($data);
	}
744103
public static function jsonUnserialize($data) {

		$report = null;

		if (!is_array($data)) {
			$data = (Array) json_decode($data, true);
		}

		if (count(array_intersect(['type', 'message', 'data'], array_keys($data))) == 3) {
			$report = new self($data['type'], $data['message'], $data['data']);
			if (isset($data['children']) && is_array($data['children'])) {
				foreach ($data['children'] as $child) {
					$report->add(static::jsonUnserialize($child));
				}
			}
		}

		return $report;
	}
992991
protected function convertArrayObjects($data)
    {
        if ($data instanceof Json\ArrayObject) {
            // @todo: Check if we need to convert arrays with only one single
            // element into non-arrays /cc cba
            $data = $data->getArrayCopy();
            foreach ($data as $key => $value) {
                $data[$key] = $this->convertArrayObjects($value);
            }
        } elseif ($data instanceof Json\JsonObject) {
            foreach ($data as $key => $value) {
                $data->$key = $this->convertArrayObjects($value);
            }
        }

        return $data;
    }
969600
public function transform($data)
    {
        if (is_array($data)) {
            return $data;
        }

        if (is_object($data) && $data instanceof Arrayable) {
            return $data->toArray();
        }

        return (array) $data;
    }
1214620
public static function format(array $data) {
        return array_map(function ($item) {
            $args = static::toArrOrNone($item);
            if (false !== $args) {
                return $args;
            }
            return $item;
        }, $data);
    }
1342395
protected function dataFormalize($data)
	{
		if(is_array($data))
		{
			$data = json_encode($data);
		}
		else if($data instanceof \DOMDocument)
		{
			$data = $data->saveXML();
		}
		else if($data instanceof \SimpleXMLElement)
		{
			$data = $data->asXML();
		}
		return $data;
	}
777918
private function dataToJson($data)
        {
            $cols = $this->getColumns($data);

            $rows = [];

            foreach ($data as $key => $row) {
                if ($key != 0 || !$this->_skipFirstRow) {
                    $c = [];

                    foreach ($row as $v) {
                        $c[] = ['v' => $v];
                    }

                    $rows[] = ['c' => $c];
                }
            }

            return json_encode(['cols' => $cols, 'rows' => $rows]);
        }