Get SCSS color variables from JSON file

How can I use JS to set CSS variables (:root) from a JSON file?
The format of my data is as follows:

css_json: 
{ 
--design-white: “#f1f2f9” 
--main-flamingo: “#8e24aa” 
}

My variables will be used as an example like this:
color: var(–main-flamingo). Which option might be more flexible in my situation?