我想用Newtonsoft創建一個JSON對象。一切看起來不錯,但我不能在空數組中創建空數組。我需要下面的輸出...C#Newtonsoft JArray。 JSON不能在空數組中創建空數組
我的代碼:
JObject rss = new JObject(
new JProperty("query",
new JObject(
new JProperty("aoi",
new JObject(
new JProperty("type", "Polygon"),
new JProperty("coordinates",
new JArray(
new JArray(
new JArray(
new JValue(-122.62664794921874),
new JValue(38.81403111409755)
),
new JArray(
new JValue(-122.62664794921874),
new JValue(38.81403111409755)
)
)
)
)
)
)
)
)
);
我能得到什麼:
{
"query": {
"aoi": {
"type": "Polygon",
"coordinates": [
[ -122.62664794921874, 38.81403111409755 ],
[ -122.62664794921874, 39.07464374293249 ]
]
}
}
}
我需要什麼:
{
"query": {
"aoi": {
"type": "Polygon",
"coordinates": [
[
[ -122.62664794921874, 38.81403111409755 ],
[ -122.62664794921874, 39.07464374293249 ]
]
]
}
}
}
在此先感謝
如何使用標準的.NET對象並對其進行序列化? –