ExtractText.cs 738 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using Newtonsoft.Json.Linq;
  4. namespace analyzeJSON
  5. {
  6. public class ExtractText
  7. {
  8. private readonly Dictionary<string, bool> keysToExtract;
  9. public ExtractText(Dictionary<string, bool> keys)
  10. {
  11. keysToExtract = keys ?? throw new ArgumentNullException(nameof(keys));
  12. }
  13. public void Extract(JToken token)
  14. {
  15. if (token.Type != JTokenType.String)
  16. return;
  17. var tokenName = AnalyzeJSON.GetNameFromPath(token.Path);
  18. if (string.IsNullOrWhiteSpace(tokenName))
  19. return;
  20. if (!keysToExtract.ContainsKey(tokenName))
  21. return;
  22. }
  23. }
  24. }