Easy Json
by| Summary | Simplifies json reading/writing by adding some extensions methods |
|---|---|
| Description |
Simplifies json reading/writing by adding some extensions methods Example of usage: public class JsonConverter : JsonConverter<Line> { public override Line? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if(typeToConvert != typeof(Line)) throw new ArgumentException($"Invalid type ({typeToConvert}).", nameof(typeToConvert)); if(reader.TokenType == JsonTokenType.Null) return null; Line line = new(); reader.ReadObjectProperties((ref reader, propertyName) => <-------- { if(propertyName.SequenceEqual("Keys"u8)) <-------- { reader.ReadArray((ref reader, index) => <-------- { line.Add(reader.getByte()); }); } } return line; } } All Features: • JsonReadException • Utf8JsonReader extensions• void AssertToken(JsonTokenType tokenType) • void AssertToken(params IEnumerable<JsonTokenType> tokenTypes) • JsonTokenType ReadOrThrow() • JsonTokenType ReadTokenOrThrow(params IEnumerable<JsonTokenType> allowedTokenTypes) • byte ReadByte() • short ReadInt16() • int ReadInt32() • long ReadInt64() • sbyte ReadSByte() • ushort ReadUInt16() • uint ReadUInt32() • ulong ReadUInt64() • float ReadSingle() • double ReadDouble() • decimal ReadDecimal() • bool ReadBoolean() • DateTime ReadDateTime() • DateTimeOffset ReadDateTimeOffset() • Guid ReadGuid() • string? ReadString() • void ReadObjectProperties(ReadPropertyDelegate readPropertyAction) • void ReadObject(ReadPropertyDelegate readPropertyAction) • void ReadArrayEntries(ReadArrayEntryDelegate readArrayEntryAction) • void ReadArray(ReadArrayEntryDelegate readArrayEntryAction) • ReadArrayEntries<T>(JsonSerializerOptions? options = null) • ReadArray<T>(JsonSerializerOptions? options = null) • Read<T>(JsonSerializerOptions? options = null) • Get<T>(JsonSerializerOptions? options = null)Simplifies json reading/writing by adding some extensions methods
Example of usage:
public class JsonConverter : JsonConverter<Line>
{
public override Line? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if(typeToConvert != typeof(Line))
throw new ArgumentException($"Invalid type ({typeToConvert}).", nameof(typeToConvert));
if(reader.TokenType == JsonTokenType.Null)
return null;
Line line = new();
reader.ReadObjectProperties((ref reader, propertyName) => <--------
{
if(propertyName.SequenceEqual("Keys"u8)) <--------
{
reader.ReadArray((ref reader, index) => <--------
{
line.Add(reader.getByte());
});
}
}
return line;
}
}
All Features:
• JsonReadException
• Utf8JsonReader extensions• void AssertToken(JsonTokenType tokenType)
• void AssertToken(params IEnumerable<JsonTokenType> tokenTypes)
• JsonTokenType ReadOrThrow()
• JsonTokenType ReadTokenOrThrow(params IEnumerable<JsonTokenType> allowedTokenTypes)
• byte ReadByte()
• short ReadInt16()
• int ReadInt32()
• long ReadInt64()
• sbyte ReadSByte()
• ushort ReadUInt16()
• uint ReadUInt32()
• ulong ReadUInt64()
• float ReadSingle()
• double ReadDouble()
• decimal ReadDecimal()
• bool ReadBoolean()
• DateTime ReadDateTime()
• DateTimeOffset ReadDateTimeOffset()
• Guid ReadGuid()
• string? ReadString()
• void ReadObjectProperties(ReadPropertyDelegate readPropertyAction)
• void ReadObject(ReadPropertyDelegate readPropertyAction)
• void ReadArrayEntries(ReadArrayEntryDelegate readArrayEntryAction)
• void ReadArray(ReadArrayEntryDelegate readArrayEntryAction)
• ReadArrayEntries<T>(JsonSerializerOptions? options = null)
• ReadArray<T>(JsonSerializerOptions? options = null)
• Read<T>(JsonSerializerOptions? options = null)
• Get<T>(JsonSerializerOptions? options = null)
|
| Votes | 👍2 👎0 ❤️1 |
| Error Rate | 0% |
| Data | {} |
| Version | Created | Size (modified) | Files | Changes |
|---|---|---|---|---|
| 229693 | 55.3 KB (10 B) | 7 ~1 | Changes on 2026-05-04 | |
| 148864 | 55.3 KB (53.3 KB) | 7 ~3 | Changes on 2026-01-31 | |
| 132747 | 46.1 KB (24.1 KB) | 7 ~2 | Changes on 2025-12-20 | |
| 130253 | 46.1 KB (46 KB) | 7 ~5 | Changes on 2025-12-04 | |
| 130243 | 19.9 KB (17.9 KB) | 7 +1 ~3 | Changes on 2025-12-04 | |
| 130237 | 15.2 KB | 6 +6 | Changes on 2025-12-04 |
Loading history…