I have a kuzzle document with a json like this:
j00:
{ '1': 'dsds',
'2': 'rer',
'5': 'yytyh hgvhg',
'8': 'koo kllkl vv'
}
currently i'am doing this to update a key :
kuzzle_doc = await get_kuzzle_doc(i,c,d);
current_value = kuzzle_doc._source.j00[key_to_modify];
new_value = modify(current_value);
kuzzle_doc._source.j00[key_to_modify] = new_value;
try {
const response = await kuzzle.document.update(
i,
c,
d,
{
j00: kuzzle_doc._source.j00
}
);
console.log('response',response);
} catch (error) {
console.error("await kuzzle.document.update ....", error);
}
- Is this the correct way to update the json ?
- what about a nested json ?
like :
{ 'a': 'dsds', 'b': 'rer', 'c': 'yytyh hgvhg', 'd': 'koo kllkl vv' 'e': {} }
What's the efficient way to update a key in the nested json ?