久久久久久久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 文件,轉換它們并保存它們

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

      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 文件,轉換它們并保存它們的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在嘗試使用 Gulp 來實現這一點.

                  I'm trying to achieve this with Gulp.

                  1. 讀取給定目錄中的每個 .json 文件,包括子目錄.
                  2. 以某種方式對其進行轉換,例如添加新的根級別等.
                  3. 將它們保存到保持原始結構的新目錄中.

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

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

                  我現在有以下骨架.

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

                  推薦答案

                  有很多方法可以做到這一點:

                  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"));
                   });
                  

                  優點:

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

                  缺點:

                  • 只有基本的輸出格式

                  (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"));
                  });
                  

                  優點:

                  • 易于使用
                  • 自動識別您的輸入文件使用的縮進(兩個空格、四個空格、制表符等)并相應地格式化您的輸出文件
                  • 支持各種js-beautify選項

                  缺點:

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

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

                  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"));
                  });
                  

                  優點:

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

                  缺點:

                  • 更難使用

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

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

                  相關文檔推薦

                  Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                  Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                  Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                  How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                  Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                  Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 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'>

                          • 主站蜘蛛池模板: 亚洲国产欧美一区 | 不卡在线一区 | 伊人精品一区二区三区 | 色.com| 国产电影一区二区三区爱妃记 | 日本网站免费观看 | 久久久久久网站 | 亚洲精品自在在线观看 | 日韩精品一区二区三区中文在线 | 久久久精品网 | 国产高清免费 | 亚洲欧美精品 | 中文字幕在线不卡播放 | 成人亚洲一区 | 午夜视频免费在线观看 | 亚洲啊v| 久久99精品久久久水蜜桃 | 国产羞羞视频在线观看 | 一区二区三区国产视频 | 99热视| 谁有毛片 | 日本中文字幕一区 | 日日干夜夜操 | 黄色三级在线播放 | 在线观看第一页 | 天天澡天天狠天天天做 | 欧美亚洲第一区 | 久久久精品一区二区三区 | 久久久青草婷婷精品综合日韩 | 欧美日韩中文在线观看 | 日韩在线精品视频 | 午夜一区二区三区在线观看 | 久精品久久 | 久久精品久久久久久 | 国内精品久久精品 | 午夜精品一区二区三区在线视频 | 国产一区二区自拍 | 亚洲欧美在线视频 | 在线中文字幕第一页 | 久久久高清 | 精品欧美一区二区三区久久久 |