簡體   English   中英

無法使用 Angular 讀取 JSON 下面的內容 7

[英]Not able to read below JSON using Angular 7

我無法閱讀下面提到的從 Rest API 收到的JSON

{
    "details": {
        "id": 21,
        "gstin": "27AACCG7831Q1Z0",
        "entityName": "GENX ENTERTAINMENT LIMITED",
        "entityPan": "AACCG7831Q",
        "entityTan": "abhishek123",
        "entityCin": "null",
        "entityWebsite": null,
        "natureOfBusiness": null,
        "constitution": "\"Public Limited Company\""
    },
    "addresses": [
        {
            "id": 22,
            "buildingName": "\"Solitaire Corporate Park\"",
            "location": null,
            "street": null,
            "buildingNo": "\"S-14\"",
            "state": "bihar",
            "district": "\"\"",
            "city": "\"\"",
            "flateNo": "\"1\"",
            "pincode": "\"400093\"",
            "isPrimary": false
        }
    ]
} 

我想把上面收到的JSON格式的數據轉換成表格。

請參閱下面的 Stakblitz 代碼

stackblit_sampleCode

希望這可以幫助..!

您的問題不清楚,但您可以使用以下方法將此值傳遞給表單:

const formValues = JSON.parse(yourJson);
this.form.values = formValues;

暫無
暫無

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

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