Skip to content
Advertisement

How To Add JSON Value in Existed Nested JSON

its possible for add new value JSON to existed nested JSON ?

My JSON its :

JavaScript

I want move the “commision” nested to “data” like this :

JavaScript

This my code for create JSON :

JavaScript

Advertisement

Answer

You can assign commission property in obj.data by using Object.assign() method and then remove the outer commission property from the object.

Working Demo :

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement