Express.js:如何在JSON中使用模板文字?

时间:2019-11-01 10:45:19

标签: json express postman wysiwyg literals

我在名为db.json的文件中拥有此JSON对象:

"lyrics": "Am9 Keep you in the dark F#m7(b5)  F7M You know they all pretend Am9 Keep you in the dark F#m7(b5)  F7M And so it all began"

,并将此代码保存在js文件中:

exports.addLyrics = (req, res, next) => {
    const lyric = req.body;
    db.get('lyrics').push(lyric).last().assign({
        id: Date.now().toString()
    }).write();

    res.status(200).send(lyric);
};

我正在使用邮递员,并且想发布带有模板文字的歌词,以便可以在正确的位置传递歌词和弦,像这样:

"lyrics": `
 Am9
Keep you in the dark
              F#m7(b5)  F7M
You know they all   pretend
 Am9
Keep you in the dark

          F#m7(b5)  F7M
And so it all    began`

问题:在这种情况下如何将模板文字存储和加载为JSON?

0 个答案:

没有答案