0

我有一组数据(键值对)需要映射到 json,注意键不固定,键名不固定。谢谢,例如

如何映射

dict<string, list<string>>
    {"Module",new List<String>(){"Allprice"}},  
        {"Code",new List<String>(){"PA0000606", "PA0000669"}},  
     {"ContinuosForwardPeriod", new List<string>() {"0"} ,
     { "TimeStampID", new List<string>{"0"},
    {"PriceTypeID": "8"}

[
 { "Module": "Allprice", 
   "Code": "PA0000606", 
   "ContinuosForwardPeriod": "0", 
   "TimeStampID": "0", 
   "PriceTypeID": "8" 
 },
 { "Module": "Allprice", 
   "Code": "PA0000669", 
   "ContinuosForwardPeriod": "0", 
   "TimeStampID": "0", 
   "PriceTypeID": "8" 
 }
]
4

1 回答 1

1
using System.Web.Script.Serialization.JavaScriptSerializer;    
JavaScriptSerializer oSerializer = new JavaScriptSerializer();
string JSON = oSerializer.Serialize(yourDict);
于 2012-09-18T22:14:01.227 回答