FluxJson.Core 0.1.1

dotnet add package FluxJson.Core --version 0.1.1
                    
NuGet\Install-Package FluxJson.Core -Version 0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FluxJson.Core" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluxJson.Core" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="FluxJson.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FluxJson.Core --version 0.1.1
                    
#r "nuget: FluxJson.Core, 0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FluxJson.Core@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FluxJson.Core&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=FluxJson.Core&version=0.1.1
                    
Install as a Cake Tool

FluxJson ๐Ÿš€

Build Status NuGet Version License: MIT

Modern, high-performance JSON serialization library for .NET with a fluent API design, focusing on speed, flexibility, and developer experience.

โœจ Features

  • ๐Ÿš€ High Performance: Near-zero allocation using Span<T>, SIMD optimizations, and performance-optimized modes
  • ๐ŸŽฏ Advanced Fluent API: Intuitive, chainable API with comprehensive configuration options
  • โšก Source Generators: Compile-time code generation with [JsonSerializable] attribute for reflection-free serialization
  • ๐Ÿ”ง Extensive Configuration: Multiple naming strategies, flexible null handling, custom DateTime formats, and converter system
  • ๐Ÿ”„ Custom Converters: Built-in converters and support for custom type conversion logic
  • โš™๏ธ Performance Modes: Speed, Balanced, and Features modes to optimize for your specific use case
  • ๐Ÿงช Comprehensive Testing: Extensive unit tests, integration tests, and benchmark suites
  • ๐Ÿ“ฆ Modern .NET: Built for .NET 8+ with latest C# features and runtime improvements

๐Ÿ“ฆ Installation

NuGet Package Manager

Install-Package FluxJson.Core

.NET CLI

dotnet add package FluxJson.Core

Package Reference

<PackageReference Include="FluxJson.Core" Version="1.0.0" />

Note: Also install FluxJson.Generator package if you want compile-time source generation support.

๐Ÿš€ Quick Start

Basic Usage

using FluxJson;

// Quick serialization and deserialization
var person = new { Name = "Alice", Age = 30 };

// Serialize to JSON
var json = Json.Serialize(person);
Console.WriteLine(json); // {"Name":"Alice","Age":30}

// Deserialize from JSON
var deserialized = Json.Deserialize<dynamic>(json);
Console.WriteLine($"Name: {deserialized.Name}, Age: {deserialized.Age}");

Advanced Fluent API

using FluxJson.Core.Configuration;

// Fluent serialization with comprehensive configuration
var user = new User
{
    FirstName = "Bob",
    LastName = "Smith",
    BirthDate = new DateTime(1990, 5, 15),
    Email = null,
    Settings = new UserSettings { Theme = "dark", Language = "en" }
};

var json = Json.From(user)
    .Configure(config => config
        .UseNaming(NamingStrategy.CamelCase)  // Convert to camelCase
        .HandleNulls(NullHandling.Ignore)     // Skip null values
        .FormatDates("yyyy-MM-dd")            // Custom date format
        .WriteIndented(true)                  // Pretty print JSON
        .WithPerformanceMode(PerformanceMode.Speed) // Optimize for speed
    )
    .ToJson();

Console.WriteLine(json);
// {
//   "firstName": "Bob",
//   "lastName": "Smith",
//   "birthDate": "1990-05-15",
//   "settings": {
//     "theme": "dark",
//     "language": "en"
//   }
// }

Source Generator Support

using FluxJson;

// Mark class for source-generated serialization (zero reflection)
[JsonSerializable]
public partial class Product : IJsonSerializable<Product>
{
    public string Name { get; set; }
    public decimal Price { get; set; }
    public string[] Tags { get; set; }
}

// Usage - automatically uses generated code
var product = new Product { Name = "Laptop", Price = 999.99m, Tags = new[] { "electronics", "gaming" } };
var json = Json.From(product).ToJson();
// Compile-time generated methods used automatically

Custom Converters

using FluxJson.Core.Converters;

// Register custom converter
JsonConfiguration.Default.Converters.Add(new CustomDateConverter());

public class CustomDateConverter : IJsonConverter
{
    // Implementation for custom date serialization/deserialization
}

๐Ÿ“Š Performance

FluxJson is engineered to outperform existing .NET JSON serialization libraries. Benchmarks are continuously run to ensure optimal performance.

Library Serialize (ops/sec) Deserialize (ops/sec) Memory (KB)
FluxJson โšก๏ธ Excellent โšก๏ธ Excellent โšก๏ธ Minimal
System.Text.Json Baseline Baseline Baseline
Newtonsoft.Json ~50% slower ~40% slower ~2x more

Note: Detailed benchmark results will be provided as the project matures and stabilizes.

๐Ÿ—๏ธ Architecture

FluxJson.Core/              # Core serialization library and public APIs
โ”œโ”€โ”€ Configuration/          # Fluent configuration API and settings management
โ”‚   โ”œโ”€โ”€ Enums.cs           # NamingStrategy, NullHandling, PerformanceMode, etc.
โ”‚   โ””โ”€โ”€ JsonConfiguration.cs # Main configuration class
โ”œโ”€โ”€ Converters/            # Built-in and custom type converters
โ”‚   โ”œโ”€โ”€ IJsonConverter.cs  # Converter interface
โ”‚   โ”œโ”€โ”€ JsonConverterAttribute.cs # Attribute for custom converters
โ”‚   โ””โ”€โ”€ BuiltInConverters.cs # Pre-built converters
โ”œโ”€โ”€ Extensions/            # Extension methods for convenience
โ”‚   โ”œโ”€โ”€ StringExtensions.cs
โ”‚   โ””โ”€โ”€ JsonConfigurationExtensions.cs
โ”œโ”€โ”€ Fluent/                # Advanced fluent API interfaces and implementations
โ”‚   โ”œโ”€โ”€ IJsonConfigurationBuilder.cs
โ”‚   โ”œโ”€โ”€ JsonConfigurationBuilder.cs
โ”‚   โ””โ”€โ”€ JsonBuilder.cs     # Fluent chaining support
โ”œโ”€โ”€ Serialization/         # Low-level serialization/deserialization logic
โ”‚   โ”œโ”€โ”€ JsonBuilder.cs     # Core serialization engine
โ”‚   โ”œโ”€โ”€ DefaultJsonBuilder.cs
โ”‚   โ”œโ”€โ”€ ReflectionBasedJsonBuilder.cs
โ”‚   โ””โ”€โ”€ JsonSerializationLogic.cs
โ””โ”€โ”€ Global features       # Core types and utilities
    โ”œโ”€โ”€ IJsonSerializable.cs
    โ”œโ”€โ”€ JsonSerializableAttribute.cs
    โ””โ”€โ”€ TypeHelpers.cs

FluxJson.Generator/        # Source Generator for compile-time optimizations
โ”œโ”€โ”€ JsonSourceGenerator.cs # Main generator with [JsonSerializable] support
โ”œโ”€โ”€ JsonSerializationGenerator.cs
โ”œโ”€โ”€ JsonDeserializationGenerator.cs
โ”œโ”€โ”€ SyntaxReceiver.cs      # Roslyn syntax analysis
โ””โ”€โ”€ ...

FluxJson.Benchmarks/       # Performance testing suite using BenchmarkDotNet
โ””โ”€โ”€ Multiple benchmark classes for comprehensive performance analysis

tests/                     # Comprehensive test suite
โ”œโ”€โ”€ FluxJson.Core.Tests/   # Unit tests for core functionality
โ”œโ”€โ”€ FluxJson.Integration.Tests/ # Integration tests
โ””โ”€โ”€ ...

โš™๏ธ Configuration Options

FluxJson offers extensive configuration options to fit any serialization scenario:

Naming Strategies

  • NamingStrategy.CamelCase: FirstName โ†’ firstName
  • NamingStrategy.SnakeCase: FirstName โ†’ first_name
  • NamingStrategy.KebabCase: FirstName โ†’ first-name
  • NamingStrategy.PascalCase: firstName โ†’ FirstName

Null Handling

  • NullHandling.Include: Include null values in output
  • NullHandling.Ignore: Skip null properties entirely

DateTime Formatting

  • DateTimeFormat.ISO8601: Standard ISO 8601 format
  • DateTimeFormat.UnixTimestamp: Unix timestamp (seconds since epoch)
  • DateTimeFormat.Custom: Use custom format string

Performance Modes

  • PerformanceMode.Speed: Maximum performance, minimal features
  • PerformanceMode.Balanced: Balance between speed and features
  • PerformanceMode.Features: Enable all features, slightly slower

Advanced Options

  • Custom converters for complex types
  • JSON pretty-printing (WriteIndented)
  • Trailing comma support
  • Case-sensitive parsing
  • Read-only property handling
  • Maximum depth limits

๐ŸŽฏ Roadmap

โœ… Completed Features

  • Project setup and core architecture
  • Initial core serialization engine
  • Advanced fluent API implementation with chaining
  • Source generator integration for basic types with [JsonSerializable] attribute
  • Multiple naming strategies (CamelCase, SnakeCase, KebabCase, PascalCase)
  • Flexible null handling (Include/Ignore)
  • Custom DateTime formatting (ISO8601, Unix timestamp, custom formats)
  • Performance modes (Speed, Balanced, Features)
  • Custom converter system with built-in converters
  • Extension methods for configuration and utilities
  • Comprehensive unit and integration test suite
  • BenchmarkDotNet performance testing suite
  • Token-based JSON parser with multiple token types
  • Attribute-based serialization control

๐Ÿšง In Progress / Planned

  • Advanced performance optimizations (SIMD, Span<T> further integration)
  • Comprehensive source generator support for complex types and configurations
  • Detailed benchmark suite with public results and comparisons
  • Extensive documentation and usage guides
  • Support for custom attributes and advanced mapping scenarios
  • JSON Schema validation and generation
  • Streaming serialization for large datasets
  • Plugin architecture for extensions
  • Integration with popular .NET web frameworks

๐Ÿค Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

๐Ÿ“„ License

This project is licensed under the MIT License - see LICENSE file for details.


Built with โค๏ธ for the .NET community. ๐Ÿš€

**Built with โค๏ธ for the .

508d4b4f8125e2354fe49d0f0dc27b9a12c1b410

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 206 9/3/2025
0.1.0-alpha 178 8/31/2025