ã°ã°ã£ã¦æåã«è¦ã¤ããã®ãrequireã使ãæ¹æ³ node.jsã§jsonãã¡ã¤ã«ã®èªã¿è¾¼ã¿ - Qiita var json = require('./test.json'); ããã§ãããã ã¨æã£ã¦é²ãã¦ããã§ããçªå¦ã¯ã¾ãã¾ããã requireã¯jsonã®å 容ãå¤ãã¾ã¾ ã¦ããããã¹ãæ¸ãã¦ã¦ããã¡ã¤ã«ãåé¤ãã¦ãã®ã«ã1ã¤ç®ã®ãã¹ãã®jsonãªãã¸ã§ã¯ããè¿ã£ã¦ããã ã©ããããrequireã¯ãªãã¸ã§ã¯ãããã£ãã·ã¥ããããã ã ãã®ä»çµã¿ãç解ãã¦ãããããªãã§ã ããã¼ãªãã§ã ããã¼ã£ã¦çµæ§ã¯ã¾ãã¾ããã jsonãã¡ã¤ã«æ¶ãã¦ããããã¡ã¤ã«ã®å 容ãæ´æ°ããã¦ãããã fs.readFileSyncã使ã ãããæ´æ°ãããjsonã®ãã¼ã¿ãèªã¿è¾¼ã¿ããã¿ãããªã¨ãã¯ã ãã£ãã·ã¥ãæ¶ãããfs.readFileSyncã§ãã¼ã¿èªã¿è¾¼ãã§jsonã«ããæ¹æ³ä½¿ãã°è§£æ±ºã fs.
{{#tags}}- {{label}}
{{/tags}}