2017-02-14 78 views
-3

下面附加的是請求JSON。任何人都可以幫助我生成/創建一個相同的請求主體。如何在C#中形成一個POST POST(Method)Json的請求體#

{ 
    "groups": [ 
    { 
     "groupName": "abc", 
     "questions": [ 
     { 
      "questionID": "", 
      "groupedIndexVlaue": 2, 
      "indexvalue": 6 
     }, 
     { 
      "questionID": "", 
      "groupedIndexVlaue": 2, 
      "indexvalue": 6 
     } 

     ] 
    }, 
    { 
     "groupName": "xyz", 
     "questions": [ 
     { 
      "questionID": "", 
      "groupedIndexVlaue": 2, 
      "indexvalue": 6 
     }, 
     { 
      "questionID": "", 
      "groupedIndexVlaue": 1, 
      "indexvalue": 7 
     } 
     ] 
    } 
    ] 
} 

我需要像下面這樣的請求體來使用post方法。請任何人建議我如何按照上述Json形成請求主體。

{ 
    "Items": [ 
    { 
     "questionID": 1, 
     "groupedIndexVlaue": 5, 
     "indexvalue": 5 
    }, 
    { 
     "questionID": 2, 
     "groupedIndexVlaue": 5, 
     "indexvalue": 5 
    } 


    ] 
} 

謝謝。

+2

你忘了來發表您嘗試 – Tinwor

+0

你只是尋找'HttpClient'對象? – David

+0

是的,我正在尋找httpclient – Manohar

回答

1

我在幾個項目上使用了RestSharp庫,它使得json的請求更加簡潔明瞭,非常靈活。

http://restsharp.org