简体   繁体   English

需要从json中提取一些值

[英]Need to extract some values from json

I am trying to get some values from json but can't figure it out here is the json string , need to extract shortcode values我试图从 json 中获取一些值,但无法弄清楚这里是 json 字符串,需要提取短代码值

check the json string file : json string检查json字符串文件: json字符串

I am using Newtonsoft for C# winforms !我正在将 Newtonsoft 用于 C# winforms!

Just have a look on this.看看这个。 here i have corrected the code which you have pasted on the comments.在这里,我更正了您粘贴在评论中的代码。 hope this will helps you to find the issue.希望这能帮助您找到问题。

        JObject o = JObject.Parse(filteredOuterhtml);
        string idValue = o["entry_data"]["ProfilePage"][0]["graphql"]["user"]["id"].ToString();
        var edges = o["entry_data"]["ProfilePage"][0]["graphql"]["user"]["edge_owner_to_timeline_media"]["edges"];
        foreach (var edge in edges)
        {
            Console.WriteLine(edge["node"]["shortcode"]);
        }

You can get shortcode using LINQ您可以使用 LINQ 获取shortcode

        var shortcodes = o["entry_data"]["ProfilePage"][0]["graphql"]["user"]["edge_owner_to_timeline_media"]["edges"].Select(x => x["node"]["shortcode"]).ToArray();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM