-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSON.cs
More file actions
50 lines (49 loc) · 1.67 KB
/
Copy pathJSON.cs
File metadata and controls
50 lines (49 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Linq;
namespace OlyCommonClasses
{
public class JSON
{
public static List<int> list_Token(JObject j1, string token)
{
if (j1.SelectToken(token) != null && j1.SelectToken(token).HasValues)
{
JArray mytoken;
mytoken = (JArray)j1.SelectToken(token);
List<int> mytokenlist;
mytokenlist = mytoken.ToObject<List<int>>();
return mytokenlist.ToList();
}
return null;
}
public static int int_Token(JObject j1, string token, int default_value = 0)
{
if (j1.SelectToken(token) != null && j1.SelectToken(token).HasValues)
{
JArray mytoken;
mytoken = (JArray)j1.SelectToken(token);
return (int)(mytoken[0]);
}
return default_value;
}
public static string string_Token(JObject j1, string token)
{
if (j1.SelectToken(token) != null && j1.SelectToken(token).HasValues)
{
JArray mytoken;
mytoken = (JArray)j1.SelectToken(token);
string combined_string = mytoken[0].ToString();
if (mytoken.Count > 1)
{
for (int i = 1; i < mytoken.Count; i++)
{
combined_string += " " + mytoken[i].ToString();
}
}
return combined_string;
}
return null;
}
}
}