2017-02-14 71 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