3 / 3
Oct 2022

Hello,
i reproduced this issue with version 21.1.20220916.
I was able to save a configuration in json format in a textbox (of config.xet). This configuration is also displayed after a new login. When reading from Api/Config the content is the same string like after my first configuration.

But after clearing the cache in the admin menu, it is not shown anymore within the configuration.
When reading from Api/Config the content is an array, like after json_decode.

How to use json-content in the configuration?
Regards, Axel

  • created

    Oct '22
  • last reply

    Oct '22
  • 2

    replies

  • 704

    views

  • 2

    users

Hmm, Api\Config automatic encodes and decodes arrays or objects.

Api\Config::read($app) reads from the cache, and only if it does not find it in the cache, eg. because you cleared the cache, it reads AND decodes it from the database. The cache itself allows to store arrays and de- and encodes them automatically. While the DB only stores strings, we have to do that manually.

Most easy is NOT to (manually) json_encode the config-values, and leave it to Api\Config to store them. When you need to send it somewhere, you json_encode it before sending.

Ralf

Ok, it makes sense for the decoding to happen automatically.
But it remains my problem that the entered JSON string is no longer displayed in the config (after cache has been cleared) and the text box remains empty.
Axel