Skip to content

echovoice/Echovoice.JSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Echovoice.JSON

NuGet Build Status Code Coverage License: Apache 2.0 Dependencies

A lightweight, high-performance JSON array encoder/decoder library for .NET. Provides simple, fast JSON array encoding and decoding without complex object mapping.

โœจ Features

  • ๐Ÿš€ Fast & Lightweight - Zero runtime dependencies, optimized for performance
  • ๐Ÿ“ฆ Multi-Platform Support - Targets .NET Framework 4.5, .NET Standard 2.0, .NET 6.0, .NET 8.0, and .NET 9.0
  • ๐ŸŽฏ Simple API - Easy-to-use static methods for encoding and decoding
  • ๐Ÿ”ง Array-Focused - Specialized for JSON array operations
  • โœ… Well-Tested - 98.31% code coverage with comprehensive unit tests using MSTest
  • ๐Ÿ“ Pretty Printing - Built-in JSON formatting with proper indentation
  • ๐Ÿ”’ No External Dependencies - Pure .NET implementation with no third-party packages
  • ๐Ÿ“ Tiny Package - Only 37KB package size

๐Ÿš€ Installation

Install via NuGet Package Manager:

dotnet add package Echovoice.JSON

Or via Package Manager Console:

Install-Package Echovoice.JSON

๐ŸŽฏ Quick Start

Decoding JSON Arrays

Simple String Array

using Echovoice.JSON;

string input = "[\"philcollins\",\"Ih8PeterG\"]";
string[] result = JSONDecoders.DecodeJsStringArray(input);

// result[0]: "philcollins"
// result[1]: "Ih8PeterG"

Complex Nested Array

string input = "[14,4,[14,\"data\"],[[5,\"10.186.122.15\"],[6,\"10.186.122.16\"]]]";
string[] result = JSONDecoders.DecodeJSONArray(input);

// result[0]: "14"
// result[1]: "4"
// result[2]: "[14,\"data\"]"
// result[3]: "[[5,\"10.186.122.15\"],[6,\"10.186.122.16\"]]"

// Decode nested arrays
string[] nested = JSONDecoders.DecodeJSONArray(result[3]);
// nested[0]: "[5,\"10.186.122.15\"]"
// nested[1]: "[6,\"10.186.122.16\"]"

Encoding JSON Arrays

String Array Encoding

string[] items = new[] { "hello", "world", "test" };
string result = JSONEncoders.EncodeJsStringArray(items);
// Result: ["hello","world","test"]

Object Array Encoding

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }

    public override string ToString()
    {
        return $"[{Age},{JSONEncoders.EncodeJsString(Name)}]";
    }
}

var people = new[]
{
    new Person { Name = "Alice", Age = 30 },
    new Person { Name = "Bob", Age = 25 }
};

string result = JSONEncoders.EncodeJsObjectArray(people);
// Result: [[30,"Alice"],[25,"Bob"]]

Pretty Printing

using Echovoice.JSON.Pretty;

string input = "[14,4,[14,\"data\"],[[5,\"10.186.122.15\"],[6,\"10.186.122.16\"]]]";
string pretty = input.PrettyPrintJson();

Output:

[
   14,
   4,
   [
      14,
      "data"
   ],
   [
      [
         5,
         "10.186.122.15"
      ],
      [
         6,
         "10.186.122.16"
      ]
   ]
]

๐Ÿ“š API Reference

JSONDecoders

Method Description
DecodeJSONArray(string s) Decodes a complex JSON array with nested structures
DecodeJsStringArray(string s) Decodes a simple JSON string array
DecodeJsString(string s) Decodes a JSON-encoded string with escape sequences

JSONEncoders

Method Description
EncodeJsStringArray(string[] s) Encodes a string array with proper escaping
EncodeJsObjectArray(object[] s) Encodes an object array (uses ToString())
EncodeJsObjectList<T>(List<T> s) Encodes a generic list (uses ToString())
EncodeJsString(string s) Encodes a single string with JSON escaping

Extensions

Method Description
string.PrettyPrintJson() Formats JSON with proper indentation
string.Slice(int start, int end) Python-like string slicing (supports negative indices)

๐Ÿ”ง Why Echovoice.JSON?

Comparison with Other Libraries

Feature Echovoice.JSON Json.NET System.Text.Json
Runtime Dependencies Zero Multiple None (built-in)
Package Size Minimal (~35KB) Large (~700KB) Built-in
Array Focus โœ… โŒ โŒ
Simple API โœ… โŒ โš ๏ธ
.NET Framework 4.5 โœ… โœ… โŒ
Performance Fast Medium Fast
Memory Footprint Minimal Large Medium

When to use Echovoice.JSON:

  • You need simple JSON array encoding/decoding
  • You want zero runtime dependencies
  • You're working with legacy .NET Framework projects
  • You need a tiny package size
  • You don't need complex object serialization
  • You want minimal memory overhead

When to use alternatives:

  • You need full JSON object serialization
  • You need LINQ-to-JSON capabilities
  • You need streaming JSON parsing

๐Ÿ› ๏ธ Development

Building from Source

git clone https://github.com/echovoice/Echovoice.JSON.git
cd Echovoice.JSON
dotnet build

Running Tests

dotnet test

Running Tests with Coverage

dotnet test --collect:"XPlat Code Coverage"

๐Ÿ“Š Code Coverage

Current code coverage: 98.31%

  • Line coverage: 98.31% (175/178)
  • Branch coverage: 97.71% (169/173)
  • Method coverage: 100% (12/12)

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

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

๐Ÿ™ Credits

๐Ÿ“ฎ Support


Made with โค๏ธ by Echovoice

About

Echovoice JSON Array Utilities

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages