Horje
c# foreach object in array json Code Example
c# foreach object in array json
// Answer By: Cam3r0n#0481
// Pro Tip : Use this to convert your JSON to C# Classes
// https://json2csharp.com/

// The example json
// {"chat":[{"author":"Bob","content":"My name is Bob and I approve this message.","timestamp":1604438166}],"error":false,"message":"Chat fetched."}

public class ChatMessage
{
    public string author;
    public string content;
    public int timestamp;
}

public class ChatResponse
{
    public List<ChatMessage> chat;
    public bool error;
    public string message;
}

ChatResponse response = JsonConvert.DeserializeObject<ChatResponse>(json);
foreach (var message in response.chat)
{
    rtbChat.AppendText($"{message.author}: {message.content}\n");
}




Csharp

Related
c# radio button checked Code Example c# radio button checked Code Example
Kill System Process in C# Code Example Kill System Process in C# Code Example
make string Code Example make string Code Example
C# datareadeer return null Code Example C# datareadeer return null Code Example
c# if statement with 2 conditions Code Example c# if statement with 2 conditions Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9