Combine several JSON files into one; fetch using jQuery / getJSON ()

I have jQuery code that retrieves content using getJSON (). There are n JSON files that are extracted from the server as needed:

/json-content/data0.json

/json-content/data1.json

/json-content/data2.json

etc...

Instead, I want to save all the JSON in a single file in order to reduce the number of HTTP requests needed to retrieve the data.

What is the best way to merge JSON files into one? If I combine the JSON files together, it no longer works with getJSON ().

UPDATE - clarified my question

+5
source share
2 answers

HTTP- , :

  • - , JSon .
  • 3 JSon JSon
  • $.getJSON() JSon

Json, .

+1

,

{
 "data1":{stuff for data1},
 "data2":{stuff for data2},
 "data3":{stuff for data3}
}

{"response":[
  {stuff for data1},
  {stuff for data2},
  {stuff for data3}]}
+4

All Articles