Guest User

Describe-JSON

a guest
Jan 5th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using FireSharp.Config;
  11. using FireSharp.Response;
  12. using FireSharp.Interfaces;
  13. using Newtonsoft.Json.Linq;
  14. using FireSharp;
  15.  
  16. namespace AuthMatrix
  17. {
  18. public partial class Form1 : Form
  19. {
  20. IFirebaseClient client;
  21. IFirebaseConfig config = new FirebaseConfig
  22. {
  23. AuthSecret = "XxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXx",
  24. BasePath = "https://a935099486553.firebaseio.com/"
  25. };
  26. List<string> DName = new List<string>();
  27. List<string> DValue = new List<string>();
  28. List<string> DPath = new List<string>();
  29. public Form1()
  30. {
  31. InitializeComponent();
  32. }
  33.  
  34. private async void button1_Click(object sender, EventArgs e)
  35. {
  36.  
  37. }
  38.  
  39. private void Form1_Load(object sender, EventArgs e)
  40. {
  41. IFirebaseClient client = new FirebaseClient(config);
  42.  
  43. FirebaseResponse response = client.Get("");
  44. JObject o = JObject.Parse(response.Body);
  45. AddValtoList(o);
  46. string checkdata = "";
  47. for (int i = 0; i < DName.Count; i++)
  48. {
  49. checkdata += String.Format("{0}. {1} : {2} ({3})\n", i + 1, DName[i], DValue[i], DPath[i]);
  50. }
  51. MessageBox.Show(checkdata);
  52. }
  53. private void AddVal(string n, string v, string p)
  54. {
  55. DName.Add(n);
  56. DValue.Add(v);
  57. DPath.Add(p);
  58. }
  59. private void AddValtoList(JObject o)
  60. {
  61. List<string> l1 = o.Properties().Select(p => p.Name).ToList();
  62. foreach (var n1 in l1)
  63. {
  64. //List<string> l3 = ((JObject)o[n1]["Task"]).Properties().Select(p => p.Name).ToList();
  65. foreach (JProperty n3 in o[n1])
  66. {
  67. foreach (JProperty n4 in o[n1]["Task"])
  68. {
  69. foreach (JProperty n5 in o[n1]["Task"][n3.Name][n4.Name])
  70. {
  71. if (n5.Value.Type.ToString() != "String")
  72. {
  73. foreach (JProperty n6 in o[n1]["Task"][n3.Name][n4.Name][n5.Name])
  74. {
  75. if (n6.Value.Type.ToString() != "String")
  76. {
  77. foreach (JProperty n7 in o[n1]["Task"][n3.Name][n4.Name][n5.Name][n6.Name])
  78. {
  79. AddVal(n7.Name, (string)n7.Value, n7.Path);
  80. }
  81. }
  82. else
  83. {
  84. AddVal(n6.Name, (string)n6.Value, n6.Path);
  85. }
  86. }
  87. }
  88. else
  89. {
  90. AddVal(n5.Name, (string)n5.Value, n5.Path);
  91. }
  92. }
  93. }
  94. }
  95.  
  96. }
  97. }
  98. }
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment