Returns field definition and value as JSON compatible array

@param string $name
@return array
185026
public function getFieldAsArray(string $name): array
    {
        $result = $this->getFieldDefinition($name);

        $result['name'] = $name;

        if (empty($result['caption'])) {
            $result['caption'] = $this->_($result['name']);
        }

        $value = $this->$name;
        $type = @$result['type'];

        if (($type == 'date' || $type == 'datetime' || $type == 'time') && is_object($value)) {
            $value = $value->format($this->translate('form.' . $type));
        }

        $result['value'] = $value;
        $result['uid'] = 'id' . uniqid();

        if (isset($result['options']) && is_array($result['options'])) {
            $options = array();

            foreach ($result['options'] as $option => $label) {
                $options[] = array('option' => $option, 'label' => $label);
            }

            $result['options'] = $options;
        }

        return $result;
    }
1285872
public function load($name)
  {
    $path = $this->_getPath($name);
    
    $data = null;
    if (file_exists($path)) {
      $serialized = file_get_contents($path);
      $data = @unserialize($serialized);
    }
    if (!is_array($data)) {
      $data = array();
    }
    
    return $data;
  }
520021
public function getField( $name )
	{
		if( !$this->hasField( $name ) )
			return NULL;
		$values	= $this->getFieldsByName( $name );
		return array_shift( $values );
	}
380213
public static function getFieldset($name) {
        if (!isset(self::$fieldsets[$name])) {
            try {
                self::$fieldsets[$name] = Fieldset::i($name);
            } catch (Exception $e) {
                return false;
            }
        }

        return self::$fieldsets[$name];
    }
1169501
public function getArrayOf(string $name) : array
    {
        $array = $this->content->hasArrayOf($name) ? $this->content->getArrayOf($name) : [];

        foreach ($array as $key => $contentGroup) {
            $array[$key] = new self($this->config, $contentGroup);
        }

        return $array;
    }
570603
protected function getFieldValue($name)
    {
        $field = $this->getField($name);

        if ($field->getSqlType()) {
            $platform = $this->getConnection()->getDatabasePlatform();

            $attributeValue = $this->getAttribute($field->getAttributeName());

            if ($name == $field->getAttributeName()) {
                return $field->convertToPHPValueSQL($attributeValue, $platform);
            }

            return $field->convertToPHPValue($attributeValue, $platform);
        }

        return $field->getValue();
    }
1266364
public function getJsonMeta($id, $name, $field = 'value') {
        $values = $this->get([$this->metaIdField => intval($id), $this->metaNameField => $name])->get($field);
        if ($values) {
            $values = @json_decode($values, true);
        }

        return $values ? $values : [];
    }
908830
public function getField($name)
    {
        return (null !== $name && array_key_exists($name, $this->fields)) ? $this->fields[$name] : null;
    }
387974
public static function json($json, $name = '...')
    {
        if (!self::isDebug()) {
            return false;
        }

        $jsonData = json_decode($json);
        $result   = self::i()->_jsonEncode($jsonData);

        return self::i()->dump($result, $name);
    }
839898
public function field($name)
    {
        if (!isset($this->fieldList[$name])) {
            $this->addField($name);
        }

        return $this->fieldList[$name];
    }
25669
public function get($name)
    {
        // For fields that are stored as arrays, like 'video'
        if (strpos($name, '.') > 0) {
            list($name, $attr) = explode('.', $name);
            if (!empty($attr) && isset($this->values[$name][$attr])) {
                return $this->values[$name][$attr];
            }
        }

        if (isset($this->values[$name])) {
            return $this->values[$name];
        }

        return false;
    }
1202837
public static function split(string $name): array
    {
        $parts = explode(self::JSON_DELIMITER, $name, 2);
        $jsonPath = count($parts) === 2 ? explode(self::JSON_DELIMITER, end($parts)) : [];

        $relationParts = explode(self::RELATION_DELIMITER, $parts[0]);

        return [
            array_slice($relationParts, 0, -1),
            end($relationParts),
            $jsonPath,
        ];
    }
1092527
protected function loadDefaultValues($name, $type = 'metadata')
    {
        $defaultValue = $this->getFileManager()->getContents(array($this->pathToDefaults, $type, $name.'.json') );
        if ($defaultValue !== false) {
            if ($this->useObjects) {
                return Utils\Json::decode($defaultValue);
            } else {
                return Utils\Json::decode($defaultValue, true);
            }
        }
        if ($this->useObjects) {
            return (object) [];
        } else {
            return array();
        }
    }
290186
public function getMeta($id, $name = null, $field = 'value') {
        if ($name) {
            $values = $this->get([$this->metaIdField => intval($id), $this->metaNameField => $name])->get($field);
        } else {
            $values = $this->findAll([$this->metaIdField => intval($id)], [
                $field,
                $this->metaNameField
            ])->toArray($field, $this->metaNameField);
        }

        return $values;
    }
534169
private function readMetaData($name) {
        $refData = [
            'ID' => '',
            'Size' => 0,
            'Offset' => 0,
            'Extension' => '',
            'FileName' => '',
            'MimeType' => '',
            'IsPartial' => true,
            'IsFinal' => false,
            'PartialUploads' => null, // unused
        ];

        $storageFileName = $this->directory . $name . '.info';
        if (file_exists($storageFileName)) {
            $json = file_get_contents($storageFileName);
            $data = Json::decode($json, Json::TYPE_ARRAY);
            if (is_array($data)) {
                return array_merge($refData, $data);
            }
        }
        return $refData;
    }
1260923
public function getValues($name)
    {
        $return = [];
        $items  = $this->getItems();

        foreach ($items as $type) {
            $method = 'get' . ucfirst($name);
            if (method_exists($type, $method)) {
                $return[] = $type->$method();
            } else {
                $return[] = $type->{$name};
            }
        }

        return $return;
    }
1051490
protected function getField($name)
    {
        if (array_key_exists($name, $this->fields)) {
            return $this->fields[$name];
        } else {
            throw new FormatterException('Field not exists');
        }
    }