WhatsAppChatParser 2.0.0

Parser for exported WhatsApp chats

Install-Package WhatsAppChatParser -Version 2.0.0
dotnet add package WhatsAppChatParser --version 2.0.0
<PackageReference Include="WhatsAppChatParser" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WhatsAppChatParser --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Parsing

using WhatsAppChatParser;

static void Main(string[] args)
{

    private readonly string filePath = @"C:\..\..WhatsApp Chat with John Doe.txt";

    // Read from file path
    IEnumerable<Message> chats = WhatsAppChat.Parse(filePath);

    // Read from stream
    chats = WhatsAppChat.Parse(new FileStream(filePath, FileMode.Open));

    foreach(var chat in chats)
        Console.WriteLine($"{chat.MessageBy} said {chat.Text} at {chat.TimeStamp}");
}

Data Serialization

WhatsAppChatParser exposes extension methods to serialize the chat list.

To JSON

JSON serialization is handled internally using Newtonsoft.Json. All the JsonConvert.SerializeObject overloads are supported.

using Newtonsoft.Json;
using WhatsAppChatParser;

static void Main(string[] args)
{

    private readonly string filePath = @"C:\..\..WhatsApp Chat with John Doe.txt";
    var chats = WhatsAppChat.Parse(filePath);

    var json = chats.ToJSON(); 
    var indentedJson = chats.ToJSON(Formatting.Indented);
}

Parsing

using WhatsAppChatParser;

static void Main(string[] args)
{

    private readonly string filePath = @"C:\..\..WhatsApp Chat with John Doe.txt";

    // Read from file path
    IEnumerable<Message> chats = WhatsAppChat.Parse(filePath);

    // Read from stream
    chats = WhatsAppChat.Parse(new FileStream(filePath, FileMode.Open));

    foreach(var chat in chats)
        Console.WriteLine($"{chat.MessageBy} said {chat.Text} at {chat.TimeStamp}");
}

Data Serialization

WhatsAppChatParser exposes extension methods to serialize the chat list.

To JSON

JSON serialization is handled internally using Newtonsoft.Json. All the JsonConvert.SerializeObject overloads are supported.

using Newtonsoft.Json;
using WhatsAppChatParser;

static void Main(string[] args)
{

    private readonly string filePath = @"C:\..\..WhatsApp Chat with John Doe.txt";
    var chats = WhatsAppChat.Parse(filePath);

    var json = chats.ToJSON(); 
    var indentedJson = chats.ToJSON(Formatting.Indented);
}

Release Notes

- Namespace changes
- Support ToJSON extension for chat list

Version History

Version Downloads Last updated
2.0.0 96 5/7/2019
1.1.0 53 5/6/2019
1.0.1 57 5/3/2019
1.0.0 59 5/3/2019