Require some tips for porting to a new save format

I have a complex json file with members within members. However I would like to add and remove a new member line to the save file for players. What is the best approach to do it?

eg: I want to change the below 

{ "money": 325, "health": 50, "mana": 30 }

to this:

{ "game": { "money": 0, "health": 0, "mana": 0 } }

without modifying the player’s stat but just changing the format

Load the old table.  See if oldTable.game is nil, if so copy the old variables to the new ones and save it back out.

Thanks for the reply!

Do I copy just by setting oldTable.game = newTable.game or do I have to loop through and copy it 1 by 1? Also I am having trouble with the below:

{ "game":[{ "name": "abc", "health": 123 }, { "name": "def", "health": 999 }] }

Is there a better way to check for it if the old save is not nil?

Is it the best to do it manually for changing save format? or is it better to use a dynamic format that loops through the whole table and check if the oldSave doesn’t have any, it will copy it to the new save?

For example if I have to change “game”, i will go to the code and change type in oldSave.game = newSave.game

Copying tables is tricky because it won’t copy nested.  Google around for Corona SDK deep copy and see what comes up.   If the old save doesn’t have a member called games, then it’s an old version, if I read your JSON right.

Load the old table.  See if oldTable.game is nil, if so copy the old variables to the new ones and save it back out.

Thanks for the reply!

Do I copy just by setting oldTable.game = newTable.game or do I have to loop through and copy it 1 by 1? Also I am having trouble with the below:

{ "game":[{ "name": "abc", "health": 123 }, { "name": "def", "health": 999 }] }

Is there a better way to check for it if the old save is not nil?

Is it the best to do it manually for changing save format? or is it better to use a dynamic format that loops through the whole table and check if the oldSave doesn’t have any, it will copy it to the new save?

For example if I have to change “game”, i will go to the code and change type in oldSave.game = newSave.game

Copying tables is tricky because it won’t copy nested.  Google around for Corona SDK deep copy and see what comes up.   If the old save doesn’t have a member called games, then it’s an old version, if I read your JSON right.