从此字符串变量获取链接 [英] Get the link from this string variable

查看:79
本文介绍了从此字符串变量获取链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从字符串中提取原始链接.该字符串包含类似这样的内容

I want to extract the original link from a string. The string contains something like this

{
    "upload": {
        "image": {
            "name": false,
            "title": "",
            "caption": "",
            "hash": "cSNjk",
            "deletehash": "ZnKGru1reZKoabU",
            "datetime": "2010-08-16 22:43:22",
            "type": "image\/jpeg",
            "animated": "false",
            "width": 720,
            "height": 540,
            "size": 46174,
            "views": 0,
            "bandwidth": 0
        },
        "links": {
            "original": "http:\/\/imgur.com\/cSNjk.jpg",
            "imgur_page": "http:\/\/imgur.com\/cSNjk",
            "delete_page": "http:\/\/imgur.com\/delete\/ZnKGru1reZKoabU",
            "small_square": "http:\/\/imgur.com\/cSNjks.jpg",
            "large_thumbnail": "http:\/\/imgur.com\/cSNjkl.jpg"
        }
    }
}





how can i get the link that''s right after original?

推荐答案

这看起来像JSON数据.
获取JSON解析器.
http://json.org/ [ ^ ]
页面底部附近有一大堆JSON实现.
或参见: ASP.NET中的JSON序列化和反序列化 [ ^ ]
This looks like JSON data.
Get a JSON parser.
http://json.org/[^]
Near the bottom of the page there is a big list of JSON implementations.
Or see: JSON Serialization and Deserialization in ASP.NET[^]


您可以逐行读取此文件,或者如果它是字符串,则为 ^ ]在Environment.NewLine上.然后,您可以获取每个字符串并检查它是否包含您的密钥,例如原始".如果是这样,则可以在:上拆分,然后获取第二个字符串,或者只是替换 [ ^ ]原始":带有string.Empty.然后,您可以用string.Empty替换,然后您将获得URL.您似乎也需要用/替换\/.
You can read this file line by line, or if it''s a string, Split[^] it on Environment.NewLine. Then you can take each string and check if it contains your key, such as ''original''. If it does, you can split on the : and then grab the second string, or just Replace[^] "Original": with string.Empty. You can then replace " with string.Empty, and you will have your URL. It looks like you need to replace \/ with /, also.


我认为您可以使用Remove()函数.删除原始"的索引.请参阅如何使用Remove()..
http://www.dotnetperls.com/remove [ http://msdn.microsoft.com/en-us/library/d8d7z2kk.aspx [ ^ ]
I think you can use Remove() function for it.remove the index of "original".See how to use Remove()..
http://www.dotnetperls.com/remove[^]
http://msdn.microsoft.com/en-us/library/d8d7z2kk.aspx[^]


这篇关于从此字符串变量获取链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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