我正在使用VB.NET中的产品,并使用NewtonSoft的JSON类来处理JSON。我不知道如何使用它,但我似乎无法确定文档。基本上,给定一个JSON字符串,我想提取金额值。下面是我有:如何使用NewtonSoft的JSON类反序列化JSON对象?
Dim serverResponse as String
Dim urlToFetch as String
Dim jsonObject as Newton.JSON.JSONConvert
Dim wc as new System.Net.WebClient
Dim amountHeld as String
urlToFetch = "someurl"
serverResponse = wc.DownloadString(urlToFetch)
jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject(serverResponse)
现在,在这一点上,我希望能够做一个
amountHeld = jsonObject.Name["amount"]
获得量的价值,但我不能。我显然是做错了。什么是正确的方法来做到这一点?
谢谢! 安东尼
什么是'serverResponse'的价值?只需在'amountHeld'行代码处添加一个断点并检查'jsonObject'的值。 – Styxxy
serverResponse保存服务器返回的JSON字符串。我已经验证了这一点。我遇到的问题是我知道如何将其分配给jsonObject,但不知道如何检索特定的键。 – CajunTechie