This is a reverse question to this question.
Given an object x={a:1,b:2}
and a string c.d=3
, modify object x to the following:
{
a:1,
b:2,
c:{
d:3
}
}
I'm looking for a solution that does not use eval
. The use case is as follows:
x
being a configuration object, we call:
config.set("music.shuffle",true)
Now, music.shuffle
must be parsed somehow and added to the internal object x
inside the config.set function, so that x looks something like:
x={a:1,b:2,music:{shuffle:true}}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…