Taking a look at the documents on jquery css if you wanted to apply these values in a single call you'd need to create valid json. Per the documents:
var validValues =
{
"background-color": "#ffe",
"border-left": "5px solid #ccc"
};
or
var validValues =
{
backgroundColor: "#ffe",
borderLeft: "5px solid #ccc"
}
then
$(selector).css(validValues);
Notice that with the DOM notation, quotation marks around the property names are optional, but with CSS notation they're required due to the hyphen in the name
specifically the reason yours does not work is the following does not create valid json for jquery:
var bgColor = "'background' : 'rgb(102,204,0)'";
var textColor = "'color' : 'rgb(40,40,40)'";
var json = {bgColor, textColor};
json =
{
bgColor: "'background' : 'rgb(102,204,0)'",
textColor: "'color' : 'rgb(40,40,40)'"
}