package utils

import (
	"encoding/json"

	"git.sr.ht/~ashkeel/containers/sync"
)

func LoadJSONToWrapped[T any](data string, sync sync.Wrapped[T]) error {
	var result T
	err := json.Unmarshal([]byte(data), &result)
	if err != nil {
		return err
	}
	sync.Set(result)
	return nil
}
