You can define your backend model to save data.
<backend_model><Namespace>\<Modulename>\Model\System\Config\Backend\SaveFileName</backend_model>
Create the file in the above path and you can use this logic to save or load data.
SaveFileName.php
namespace Namespace\Modulename\Model\System\Config\Backend;
class SaveFileName extends \Magento\Framework\App\Config\Value
{
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Framework\Math\Random $mathRandom,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
/**
* Prepare data before save
*
* @return $this
*/
public function beforeSave()
{
$value = $this->getValue();
$result = [];
foreach ($value as $data) {
//apply your logic here
//save your data in result array
}
$this->setValue(serialize($result)); // serialize your data
return $this;
}
}