JSON转换为C#中的字符串数组 [英] JSON to string array in C#

查看:67
本文介绍了JSON转换为C#中的字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我就是这样的JSON字符串

I have JSON string just like that

[
    {
        "markers": {
            "0": "13.775801,100.611199",
            "1": "13.775801,100.611199" 
        } 
    }
]

我想用字符串数组做标记列表.我的JSON格式与该格式完全相同,可能不再更改了,我该怎么做?

I would like to do markers list with string array.My JSON format is exactly same with that format.It might not be change anymore.How can I do for that ?

推荐答案

JavaScriptSerializer 是一个不错的选择.它在 .NET Framework v3.5 中,因此您不需要任何 3rd Party 库.

JavaScriptSerializer is a good option. It is in .NET Framework v3.5, so you won't need any 3rd Party library.

此处是有关如何使用的一个小示例它,尽管如果您在Google上输入 JavaScriptSerializer ,您将有很多解析它的示例.

Here is an small example of how you can use it, although if you enter JavaScriptSerializer on Google, you will have lots of examples of how to parse it.

基本上,您需要定义一种适合您需要解析的JSON格式的类型,并使用JavaScriptSerializer类的Deserialize方法.

Basically, you need to define a type that fits the JSON format you need to parse, and use the Deserialize method of JavaScriptSerializer class.

有关类似问题,请参见@Marc Gravell的答案:使用Json.net解析JSON

See @Marc Gravell's answer for a similar question: Parsing JSON using Json.net

这篇关于JSON转换为C#中的字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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