about summary refs log tree commit diff
path: root/LibMatrix.EventTypes/MatrixEventContent.cs
blob: c30ebb04c66c8442dd1419d26b63b89bd54d6a5a (plain) (blame)
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
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;

namespace LibMatrix.EventTypes;

/// <summary>
///     Extensible Event Content, aims to provide an API similar to JsonNode/JsonObject
///     <seealso cref="System.Text.Json.Nodes.JsonNode"/>
///     <seealso cref="System.Text.Json.Nodes.JsonObject"/>
/// </summary>
public class MatrixEventContent {
    // <T> : MatrixEventContent where T : MatrixEventContent<T>, new() {
    internal JsonNode _json = new JsonObject();

    public static implicit operator MatrixEventContent(JsonNode json) => new(json);

    [JsonConstructor]
    public MatrixEventContent(JsonNode json) {
        _json = json;
    }

    public MatrixEventContent() { }

    public JsonNode? this[string key] => _json[key];
}