const jsonString = JSON.stringify(myJson, null, 2);
{
"object1": {
"subobject1": {
"r": 0,
"g": 0,
"b": 0
},
"someOtherProperty": 1
},
"allColors": {
"object2": [
{
"subobject2": {
"r": 4,
"g": 5,
"b": 6
},
"subobject3": {
"r": 7,
"g": 8,
"b": 9
},
"subobject4": {
"r": 9,
"g": 10,
"b": 11
}
}
......
......
}
What is the correct regex and way in JS to replace all r
, g
, b
values with hex inside the same string object? For example:
"subobject2": {
"r": 4,
"g": 5,
"b": 6
}
would turn into:
"subobject2": "#040506"