Jump to content

Combining/Merging two json files


IKStreamIvo
 Share

Recommended Posts

Hey,

I am working on a game that fetches an unknown amount of json files from a webserver. When everything is parsed, I need to combine everything in one big json object. 

//for loop
game.load.json('cards' + i, deckStorageLink + decksData[i][0]);
//while testing im only having two, 'cards0' and 'cards1'

//different function
var deck1 = game.cache.getJSON('cards0');
var deck2 = game.cache.getJSON('cards1');

var fullDeck = //deck1 and deck2 combined.

so if I have

[
    {
        "country": "0",
        "points": "1",
        "action": "5",
        "description": "Draw two cards"
    }
]

and

[
    {
        "country": "1",
        "points": "1",
        "action": "3",
        "description": "Steal a card"
    }
]

I want

[
    {
        "country": "0",
        "points": "1",
        "action": "5",
        "description": "Draw two cards"
    }
]
[
    {
        "country": "1",
        "points": "1",
        "action": "3",
        "description": "Steal a card"
    }
]

 

Does anyone know how to do this? 

 

-Ivo

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...