我需要能够在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
提前致谢
答案 0 :(得分:0)
Json.NET是正确的方法。 也许this可以帮到你。
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
...尚未对它进行测试,但我希望它能带您走上正轨。