"player_stats_1" { "Player1" //'Player1' is present only in this file { "score" "2123" "kills" "1245" "deaths" "754" } "Player2" //'Player2-4' are present in both files { "score" "132" "kills" "511" "deaths" "421" } "Player3" //Each player stats present in both files have different key values { "score" "12" "kills" "21" "deaths" "23" } "Player4" { "score" "123" "kills" "32" "deaths" "21" } //No 'Player5' here }
"player_stats_2" { //No 'Player1' here "Player2" { "score" "532" "kills" "123" "deaths" "75" } "Player3" { "score" "321" "kills" "54" "deaths" "12" } "Player4" { "score" "154" "kills" "123" "deaths" "213" } "Player5" //'Player5' is present only in the second file { "score" "75" "kills" "12" "deaths" "232" } }
"player_stats_merged" { "Player1" //No 'Player1' in the second file so just copy this section over { "score" "2123" "kills" "1245" "deaths" "754" } "Player2" //Add score of 'Player2' from the first file to the score of 'Player2' from the second file, { //do it for every key of its respective section and for every section in the file. "score" "*added score*" //(I won't be bothering calculating all these values, you get the idea :p) "kills" "*added kills*" "deaths" "*added deaths*" } "Player3" { "score" "*added score*" "kills" "*added kills*" "deaths" "*added deaths*" } "Player4" { "score" "*added score*" "kills" "*added kills*" "deaths" "*added deaths*" } "Player5" //No 'Player5' in the first file so just copy this section over { "score" "75" "kills" "12" "deaths" "232" } }