JSON響應我使用小巧玲瓏返回一個IEnumerable<dynamic>
物體的簽名:ASP.NET MVC格式從動態
date: 01/01/2011
VarName = "VariableX"
VariableValue = "Value 1"
date: 01/01/2011
VarName = "VariableY"
VariableValue = "Value 2"
我希望把它變成一個JSON響應:
{ date: 01/01/2011
VariableX: Value 1
VariableY: Value 2
}
..等,並會從任何一點開始!
感謝
編輯:
如果我變平作爲其返回我看對象:
[
{"date":"\/Date(1331683206000)\/","VariableName":"Variable1","VariableValue":"ValueX"},
{"date":"\/Date(1331683206000)\/","VariableName":"Variable2","VariableValue":"ValueY"},
{"date":"\/Date(1331683206000)\/","VariableName":"Variable3","VariableValue":"ValueZ"}
]
什麼,我基本上是在尋找指導是如何翻轉出來,所以它閱讀:
[
{"date":"\/Date(1331683206000)\/","Variable1","ValueX"},
{"date":"\/Date(1331683206000)\/","Variable2","ValueY"},
{"date":"\/Date(1331683206000)\/","Variable3","ValueZ"},
]
編輯#2:固定所需輸出到:
[
{
"date": "/Date(1331683206000)/",
"Variable1": "ValueX"
},
{
"date": "/Date(1331683206000)/",
"Variable2": "ValueY"
},
{
"date": "/Date(1331683206000)/",
"Variable3": "ValueZ"
}
]
編輯#3:
{
"date": "/Date(1331683206000)/",
"Variable1": "ValueX",
"Variable2": "ValueY",
"Variable3": "ValueZ"
},
{
"date": "/Date(1431683206000)/",
"Variable1": "ValueX",
"Variable2": "ValueY",
"Variable3": "ValueZ"
},
{
"date": "/Date(151683206000)/",
"Variable1": "ValueX",
"Variable2": "ValueY",
"Variable3": "ValueZ"
}
你提的問題不夠清楚。目前缺少的是到目前爲止您嘗試過的代碼以及您遇到什麼困難。 –
謝謝 - 我已經添加了更多信息 – chrr
好吧,現在更清楚了。你試圖實現的是不可能的,因爲你顯示的是無效的JSON。 –