Nodejs dynamic update function issue

Hi, I am using nodejs, is there any way to dynamically generate the ExpressionAttributeValues and the UpdateExpression for a nested json object like:
{
“id”: “12345”,
“sub”:{
“firstname”: “John”,
“lastname”: “Doe”,
“type”:{
“tyepid”: “7”,
“typename”: “ch”,
“otherole”: “other role”
},
“email”: "k.d@abc.com"
}}