[英]How to Convert Json Array to Single JSON object without using T object in C#?
我正在尋找一種將 Json 數組 [{},{}] 轉換為 object => [{}] 的單線器。
我有以下序列化的 JSON 字符串,
[
{
"Address": "Adresse"
},
{
"AddressDetails": "Détails de l'adresse"
},
{
"BackToLoginPage": "Retour à la page de connexion"
}
]
Now I want to convert this into the following format without using one type or model object because the data is dynamic and it's going to contain 1000 number of fields so, I can not create a model type object with dynamic properties. 那么有沒有辦法將它轉換成一個單一的 JSON 對象/字符串? 它看起來很簡單,但我無法轉換它。
[
"Address": "Adresse",
"AddressDetails": "Détails de l'adresse",
"BackToLoginPage": "Retour à la page de connexion"
]
Newtonsoft.Json.Linq 可以解析/處理 JSON 沒有 Z20F35E630JFArray394DBFA8C3ObjectJF6) 這是一個班輪:
var mergedJson = new JObject(JArray.Parse(json).OfType<JObject>().SelectMany(o => o.Properties()).GroupBy(p => p.Name).Select(grp => grp.First())).ToString();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.