JSon 在 C# 中多次查找多个特定值

JSon Find multiple specific Values multiple times in C#

我想搜索或迭代一个非常大的 JSon 并在每次出现时找到 3 个键值对。有什么方法或功能可以帮助我做到这一点吗?甚至有可能吗?

我需要找到第一个值,然后从那个点开始找到第二个,然后是第三个,然后又是第一个。 我知道有用于字符串的 FindAll,但是将 JSon 作为字符串处理并不是那么好。

编辑:我正在使用 C#

如果您的数据量很大,那么我建议将内容流式传输并进行处理。

为此你可以使用 JsonTextReader - https://www.newtonsoft.com/json/help/html/ReadJsonWithJsonTextReader.htm

    var filePath = Path.GetTempFileName();

    File.WriteAllText(filePath, "{bigJson: true}");

    var stream = File.Open(filePath, FileMode.Open);

    JsonTextReader reader = new JsonTextReader(new StreamReader(stream));
    while (reader.Read())
    {
        if (reader.Value != null)
        {
            Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value);
        }
        else
        {
            Console.WriteLine("Token: {0}", reader.TokenType);
        }
    }