使用Json.Net将namevaluecollection转换为Json [英] converting a namevaluecollection to Json using Json.Net

查看:208
本文介绍了使用Json.Net将namevaluecollection转换为Json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Json的新手,我在网上使用了一些示例,并尝试将namevaluecollection转换为Json(使用json.net nuget包),并且转换后我只看到The Key而不是json字符串中的值.我想念的是什么.

I am a newbie to Json, I have used some examples online and tried to convert a namevaluecollection to a Json (using json.net nuget package) and I only see The Key not the value in my json string after conversion. What am i missing.

 Dim JSONString As String = ""
Dim test As NameValueCollection = New NameValueCollection
                test.Add("1", "One")
                test.Add("2", "Two")
                test.Add("3", "Three")

                JSONString = JsonConvert.SerializeObject(test)

运行时我的Json字符串中的结果显示在下面的屏幕快照中.

The result in my Json string during runtime is shown in the below screenshot.

请忍受我,我对Json真的很陌生,更不用说对json进行序列化和反序列化了.

Please bear with me I am really new to Json and let alone serialising and deserialising json.

推荐答案

将NameValueCollection转换为字典

Convert NameValueCollection to Dictionary

这篇关于使用Json.Net将namevaluecollection转换为Json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆