2017-09-21 77 views
0

我的JSON文件位於以下路徑,我想將它們組合成一個JSON,其中的鍵等於文件的名稱。使用grunt-concat-json排除輸出中的目錄結構

src/ 
    john/ 
    doe/ 
     one.json 
     two.json 
     three.json 

如果我的呼嚕聲,CONCAT,JSON的結構是這樣的:

"concat-json": { 
     "en": { 
      src: "src/john/doe/*.json", 
      dest: "output.json" 
     } 
    } 

output.json:

{ 
"src": { 
    "john": { 
     "doe": { 
     one: {...}, 
     two: {...} 
     } 
    } 
    } 
} 

我希望我的output.json是

{ 
    one: {...}, 
    two: {...} 
} 

我該如何做到這一點? 謝謝。

回答

0

下面是解:

更改的concat-JSON在咕嚕如下:

"concat-json": { 
     "en": { 
      src: "**/*.json", 
      cwd: "src/john/doe", 
      dest: "output.json" 
     } 
    } 

這裏output.json將是:

{ 
    one: {...}, 
    two: {...} 
}