1 // Answer By: Cam3r0n#0481- edited by wethecom
2// Pro Tip : Use this to convert your JSON to C# Classes
3// https://json2csharp.com/
4
5// The example json
6// {"chat":[{"author":"Bob","content":"My name is Bob and I approve this message.","timestamp":1604438166}],"error":false,"message":"Chat fetched."}
7
8public class ChatMessage
9{
10 public string author;
11 public string content;
12 public int timestamp;
13}
14
15public class ChatResponse
16{
17 public List<ChatMessage> chat;
18 public bool error;
19 public string message;
20}
21var json = @"{"chat":[{"author":"Bob","content":"My name is Bob and I approve this message.","timestamp":1604438166}],"error":false,"message":"Chat fetched."}
22";
23ChatResponse response = JsonConvert.DeserializeObject<ChatResponse>(json);
24foreach (var message in response.chat)
25{
26 rtbChat.AppendText($"{message.author}: {message.content}\n");
27}
1// Answer By: Cam3r0n#0481
2// Pro Tip : Use this to convert your JSON to C# Classes
3// https://json2csharp.com/
4
5// The example json
6// {"chat":[{"author":"Bob","content":"My name is Bob and I approve this message.","timestamp":1604438166}],"error":false,"message":"Chat fetched."}
7
8public class ChatMessage
9{
10 public string author;
11 public string content;
12 public int timestamp;
13}
14
15public class ChatResponse
16{
17 public List<ChatMessage> chat;
18 public bool error;
19 public string message;
20}
21
22ChatResponse response = JsonConvert.DeserializeObject<ChatResponse>(json);
23foreach (var message in response.chat)
24{
25 rtbChat.AppendText($"{message.author}: {message.content}\n");
26}