我有一个API调用,它看起来像的结果:自定义JSON,转换为对象
{"Operations":[{"OperationId":"2","OperationObjectId":"Application","OperationName":"UnlockSession","OperationParameters":[{"Name":"viewModel","Value":"model"},{"Name":"returnUrl","Value":"https://"}],"OperationCaller":{"UserPrincipalName":"bob","ClientIPAddress":""},"OperationResult":"Succeeded","OperationStatus":200,"OperationRequest":{"Method":"POST","Url":""},"OperationStartedTime":"2013-08-20T12:04:17.5462357Z","OperationCompletedTime":"2013-08-20T12:04:17.9979469Z"}],"ContinuationToken":null}
理想我想将它转换为对象,所以我可以做的东西,如:
object.OperationObjectID; // gives Application
object.Method; // gives POST
object.OperationResult; // gives Succeeded
有人知道这是怎么完成的吗? JSON解析是否需要知道格式?
感谢, 安德鲁
什么是 “自定义” JSON是什么意思? –
请看看这个StackOverflow的答案: [http://stackoverflow.com/questions/2246694/how-to-convert-json-object-to-custom-c-sharp-object][1] [1]:http://stackoverflow.com/questions/2246694/how-to-convert-json-object-to-custom-c-sharp-object – RRR
使用[json.net](http://james.newtonking的.com /项目/ JSON-net.aspx) –