在理想情况下将JSON字符串解析为VB或C#作为最后的手段



我需要能够在VB或C#中理想地解析以下字符串,如果不是VB - 我尝试了许多在线找到但无法工作的方法 - 是否有人可以快速工作示例代码可以帮助我吗?

我尝试使用json.net/newtonsoft,但没有任何地方 - 有点生锈!

Dim json As String = "[{""posX"":36,""posY"":74,""data"":{""type"":""A""},""html"":""A""},{""posX"":243,""posY"":77,""data"":{""type"":""A""},""html"":""A""},{""posX"":32,""posY"":279,""data"":{""type"":""B""},""html"":""B""},{""posX"":242,""posY"":285,""data"":{""type"":""c""},""html"":""c""}]"

我感兴趣的值是POSX,POSY和HTML

预先感谢

json.net是正确的方法。也许这可以帮助您。

Dim json As String = "{'position':[{""posX"":36,""posY"":74,""data"":{""type"":""A""},""html"":""A""},{""posX"":243,""posY"":77,""data"":{""type"":""A""},""html"":""A""},{""posX"":32,""posY"":279,""data"":{""type"":""B""},""html"":""B""},{""posX"":242,""posY"":285,""data"":{""type"":""c""},""html"":""c""}]}"
Dim result = JsonConvert.DeserializeObject(json)
Console.WriteLine(result("position")(0)("posX") & " - " & result("position")(0)("posY") & " - " & result("position")(0)("html"))

输出应为

36-74- a

...尚未测试它,但我希望它能使您在正确的轨道上。

相关内容

  • 没有找到相关文章

最新更新