簡體   English   中英

在 Node.js 中創建新 JSON 對象的問題

[英]Issues creating a new JSON object in Node.js

對不起,我是編程新手,請有人幫忙。 我可以記錄配置文件對象,一個包含 10 個項目的 JSON 對象,但我不能記錄應該只包含 3 個的 vehQ。我寫錯了嗎?

        let profile = await this.getProfileDetails(params)
        console.log(profile)
            var vehQ = {}
            if (profile ) {

                vehQ["profileID"] = profile[0].profileID
                vehQ["regNumber"] = profile[0].regNumber
                vehQ["compatibility"] = profile[0].compatibility
                console.log(vehQ)

您可能將 JSON 作為字符串接收,您需要將其解析為 JS 對象。

const parsedProfile = JSON.parse(profile);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM