The way I’d do this in Fortran is to use fpm as a dependency to the plugin fpm package, so you don’t have to redefine fpm’s internal package derived type (it took me a long while to understand it lol).
Because all fpm derived types are now serializable_t, they can be fully loaded/dumped to JSON. For example, just load the fpm_module_t from file:
use fpm_model, only: fpm_model_t
implicit none
type(fpm_model_t) :: my_package
logical :: error
call my_package%load(file="model_dump.json", error, json=.true.) ! if JSON input
call my_package%load(file="model_dump.toml", error, json=.false.) ! if TOML input
That will load everything back into the fpm_model_t structure.
PS I’ve never used fpm as a dependency to another package, but I don’t see why it shouldn’t work!