簡體   English   中英

如何將 JSON 數據數組 object 轉換為自定義字符串?

[英]How to convert JSON data array object to custom string?

當前結果:

master data :`[object Object]`

with stringify: 

    [{"bundlingId":"10547","countqtybuy":1}, 
     {"bundlingId":"19386","countqtybuy":2}]

with toString: `[object Object]`

with toString + stringify: 

    [{"bundlingId":"10547","countqtybuy":1},
     {"bundlingId":"19386","countqtybuy":2}]

我的預期結果:

10547,1;19386,2

因為我看到你在錯誤的軌道上,所以我為你發布了這個

 const obj = JSON.parse`[{"bundlingId":"10547","countqtybuy":1}, {"bundlingId":"19386","countqtybuy":2}]` const values = obj.map(item => Object.values(item).join(",")).join(";") console.log(values)

暫無
暫無

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

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