如何使用anularr 9将datzs转换为jason格式

问题描述 投票:0回答:1

enter image description here我必须创建一个像这样的jason格式

{
   "Description":"Godown1",
   "InCharge":1,
   "ContactNumber":"94965241256",
   "Address":"addressdetails",
   "RackDetails":[
      {
         "Description":"R1"
      },
      {
         "Description":"R2"
      },
      {
         "Description":"R2"
      }
   ]
}

但是iam的格式如下

{"Description":"Godown1","InCharge":"1","ContactNumber":"94965241256","Address":"addressdetails"}
{"Description":"R1"},{"Description":"R2[enter image description here][2]"}
angular typescript
1个回答
0
投票

您可以在使用stringify时缩进结果:

JSON.stringify(myObject, null, 2)

其中2是缩进级别。

© www.soinside.com 2019 - 2024. All rights reserved.