久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='p4mhd'></tfoot>

        <i id='p4mhd'><tr id='p4mhd'><dt id='p4mhd'><q id='p4mhd'><span id='p4mhd'><b id='p4mhd'><form id='p4mhd'><ins id='p4mhd'></ins><ul id='p4mhd'></ul><sub id='p4mhd'></sub></form><legend id='p4mhd'></legend><bdo id='p4mhd'><pre id='p4mhd'><center id='p4mhd'></center></pre></bdo></b><th id='p4mhd'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='p4mhd'><tfoot id='p4mhd'></tfoot><dl id='p4mhd'><fieldset id='p4mhd'></fieldset></dl></div>

        <small id='p4mhd'></small><noframes id='p4mhd'>

        <legend id='p4mhd'><style id='p4mhd'><dir id='p4mhd'><q id='p4mhd'></q></dir></style></legend>
          <bdo id='p4mhd'></bdo><ul id='p4mhd'></ul>
      1. 讀取一堆 JSON 文件,轉(zhuǎn)換它們并保存它們

        Read a bunch of JSON files, transform them, and save them(讀取一堆 JSON 文件,轉(zhuǎn)換它們并保存它們)

      2. <i id='5h3F0'><tr id='5h3F0'><dt id='5h3F0'><q id='5h3F0'><span id='5h3F0'><b id='5h3F0'><form id='5h3F0'><ins id='5h3F0'></ins><ul id='5h3F0'></ul><sub id='5h3F0'></sub></form><legend id='5h3F0'></legend><bdo id='5h3F0'><pre id='5h3F0'><center id='5h3F0'></center></pre></bdo></b><th id='5h3F0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5h3F0'><tfoot id='5h3F0'></tfoot><dl id='5h3F0'><fieldset id='5h3F0'></fieldset></dl></div>
        <tfoot id='5h3F0'></tfoot>

          • <bdo id='5h3F0'></bdo><ul id='5h3F0'></ul>

                <tbody id='5h3F0'></tbody>
              <legend id='5h3F0'><style id='5h3F0'><dir id='5h3F0'><q id='5h3F0'></q></dir></style></legend>
                • <small id='5h3F0'></small><noframes id='5h3F0'>

                  本文介紹了讀取一堆 JSON 文件,轉(zhuǎn)換它們并保存它們的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  我正在嘗試使用 Gulp 來實(shí)現(xiàn)這一點(diǎn).

                  I'm trying to achieve this with Gulp.

                  1. 讀取給定目錄中的每個(gè) .json 文件,包括子目錄.
                  2. 以某種方式對(duì)其進(jìn)行轉(zhuǎn)換,例如添加新的根級(jí)別等.
                  3. 將它們保存到保持原始結(jié)構(gòu)的新目錄中.

                  我迷失的地方是如何通過管道讀取/寫入 JSON 到 src.

                  The point where I'm lost is how to pipe reading/writing JSON to src.

                  我現(xiàn)在有以下骨架.

                  gulp.task("migratefiles", function () {
                    return gulp.src("files/**/*.json")
                        .pipe(/* WHAT HERE? */)
                        .pipe(gulp.dest("processed"));
                  });
                  

                  推薦答案

                  有很多方法可以做到這一點(diǎn):

                  There's a number of way you can do this:

                  (1) 使用 gulp-json-transform 插件:

                  var jsonTransform = require('gulp-json-transform');
                  
                  gulp.task("migratefiles", function () {
                    return gulp.src("files/**/*.json")
                      .pipe(jsonTransform(function(json, file) {
                        var transformedJson = {
                          "newRootLevel": json
                        };
                        return transformedJson;
                      }))
                      .pipe(gulp.dest("processed"));
                   });
                  

                  優(yōu)點(diǎn):

                  • 易于使用
                  • 支持異步處理(如果你返回一個(gè) Promise)
                  • 允許訪問每個(gè)文件
                  • 的路徑

                  缺點(diǎn):

                  • 只有基本的輸出格式

                  (2) 使用 gulp-json-editor 插件:

                  var jeditor = require('gulp-json-editor');
                  
                  gulp.task("migratefiles", function () {
                     return gulp.src("files/**/*.json")
                       .pipe(jeditor(function(json) {
                         var transformedJson = {
                           "newRootLevel": json
                         };
                         return transformedJson;
                       }))
                       .pipe(gulp.dest("processed"));
                  });
                  

                  優(yōu)點(diǎn):

                  • 易于使用
                  • 自動(dòng)識(shí)別您的輸入文件使用的縮進(jìn)(兩個(gè)空格、四個(gè)空格、制表符等)并相應(yīng)地格式化您的輸出文件
                  • 支持各種js-beautify選項(xiàng)

                  缺點(diǎn):

                  • 似乎不支持異步處理
                  • 似乎沒有辦法訪問每個(gè)文件的路徑

                  (3) 手動(dòng)操作(直接訪問 vinyl 使用 map-stream 的文件對(duì)象):

                  var map = require('map-stream');
                  
                  gulp.task("migratefiles", function () {
                     return gulp.src("files/**/*.json")
                       .pipe(map(function(file, done) {
                         var json = JSON.parse(file.contents.toString());
                         var transformedJson = {
                           "newRootLevel": json
                         };
                         file.contents = new Buffer(JSON.stringify(transformedJson));
                         done(null, file);
                       }))
                       .pipe(gulp.dest("processed"));
                  });
                  

                  優(yōu)點(diǎn):

                  • 完全控制/訪問所有內(nèi)容
                  • 支持異步處理(通過 done 回調(diào))

                  缺點(diǎn):

                  • 更難使用

                  這篇關(guān)于讀取一堆 JSON 文件,轉(zhuǎn)換它們并保存它們的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運(yùn)算符上的意外令牌)
                  Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標(biāo)志傳遞給 Gulp 以使其以不同的方式運(yùn)行任務(wù)?)
                  Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                  How to run Gulp tasks sequentially one after the other(如何一個(gè)接一個(gè)地依次運(yùn)行 Gulp 任務(wù))
                  Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                  Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時(shí) Visual Studio 2015 崩潰)
                • <i id='PhrCH'><tr id='PhrCH'><dt id='PhrCH'><q id='PhrCH'><span id='PhrCH'><b id='PhrCH'><form id='PhrCH'><ins id='PhrCH'></ins><ul id='PhrCH'></ul><sub id='PhrCH'></sub></form><legend id='PhrCH'></legend><bdo id='PhrCH'><pre id='PhrCH'><center id='PhrCH'></center></pre></bdo></b><th id='PhrCH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PhrCH'><tfoot id='PhrCH'></tfoot><dl id='PhrCH'><fieldset id='PhrCH'></fieldset></dl></div>

                    <tbody id='PhrCH'></tbody>

                        • <bdo id='PhrCH'></bdo><ul id='PhrCH'></ul>
                        • <tfoot id='PhrCH'></tfoot>
                        • <legend id='PhrCH'><style id='PhrCH'><dir id='PhrCH'><q id='PhrCH'></q></dir></style></legend>

                          • <small id='PhrCH'></small><noframes id='PhrCH'>

                          • 主站蜘蛛池模板: 国产不卡在线播放 | 夜夜摸天天操 | 精品国产一区二区 | 国产在线视频在线观看 | 最新中文字幕 | 日韩在线欧美 | 91精品国产91久久久久久不卞 | 国产午夜精品一区二区三区 | 亚洲精品在线国产 | 亚洲精品福利在线 | 国产精品v | 国产精品欧美一区二区三区不卡 | 狠狠色狠狠色综合系列 | 激情av免费看 | 日日日操 | 国产成人高清成人av片在线看 | 欧美一级特黄aaa大片在线观看 | 美美女高清毛片视频免费观看 | 免费成人国产 | 亚洲国产91 | 可以看黄的视频 | 久久99精品久久久 | 老头搡老女人毛片视频在线看 | 亚洲天堂一区二区 | 免费高清成人 | 日本特黄a级高清免费大片 成年人黄色小视频 | 一区二区三区中文字幕 | 免费在线观看成年人视频 | 久久激情视频 | 日韩电影免费在线观看中文字幕 | 国产精品国产精品国产专区不卡 | 亚洲天堂精品久久 | 中文字幕精品一区久久久久 | 欧美aaaaaaaa| 午夜视频在线观看网址 | 欧美a在线 | 日韩av在线不卡 | 精品一区二区三区在线观看 | 免费一级网站 | 国产激情91久久精品导航 | 国产精品久久久久久久久动漫 |