Sorry, I didn't really know what to put in title, I hope the example will be enough
我有一个这样的对象:
{
'key[0]': 'value 0',
'key[1]': 'value 1',
'key[2]': 'value 2'
}
我想要一个像这样的物体:
^{pr2}$另一个我能收到的东西是这样的:
{
'key[subkey0]': 'value 0',
'key[subkey1]': 'value 1',
'key[subkey2]': 'value 2'
}
我想得到:
{
'key': {
'subkey0': 'value 0',
'subkey1': 'value 1',
'subkey2': 'value 2'
}
}
我的问题是,有没有lib能做到这一点?如果没有,最有效/优化的方法是什么?在
You can consider that in the first case the list I received will be always complete, that means that no number will be skipped
从这里开始:
输出:
^{pr2}$对于第一个案子
按
[
拆分旧字典键之一以获得真正的键。然后用这个键构造新的dict。我觉得这是一种不好的做法,但它很管用。所以你可以看看。在相关问题 更多 >
编程相关推荐