TEasyJson is a powerful and intuitive Delphi class that simplifies JSON manipulation. Designed with a fluent interface, it enables developers to seamlessly create, modify, and traverse JSON objects and arrays using method chaining. Whether handling simple key-value pairs or deeply nested structures, TEasyJson ensures efficiency, readability, and flexibility.
- π Fluent interface for effortless JSON manipulation
- π Supports both JSON objects and arrays
- π Chainable methods for concise and readable code
- ποΈ Easily constructs and modifies nested JSON structures
- π¨ Provides formatted JSON output for better readability
- β‘ Optimized for performance and efficiency
Getting started with TEasyJson is quick and easy:
- Copy
TEasyJson.pasinto your project. - Add
TEasyJsonto yourusesclause. - Start Coding! Enjoy simplified JSON handling with method chaining.
var EJ: TEasyJson;
begin
EJ := TEasyJson.Create;
EJ.Put('name', 'Alice')
.Put('age', 25)
.AddArray('hobbies')
.Put(0, 'Reading')
.Put(1, 'Cycling');
WriteLn(EJ.Format());
end;{
"name": "Alice",
"age": 25,
"hobbies": [
"Reading",
"Cycling"
]
}var EJ: TEasyJson;
begin
EJ := TEasyJson.Create('{"name":"John","age":30}');
WriteLn(EJ.Format());
end;EJ.Put('email', 'alice@example.com');
EJ.Put('age', 26); // Updates existing keyvar EJ: TEasyJson;
begin
EJ := TEasyJson.Create;
EJ.AddArray('numbers')
.Put(0, 10)
.Put(1, 20)
.Put(2, 30);
WriteLn(EJ.Format());
end;EJ.AddObject('address',
function(E: TEasyJson): TEasyJson
begin
Result := E.Put('city', 'New York')
.Put('zip', '10001');
end);WriteLn(EJ['name'].AsString); // Alice
WriteLn(EJ['age'].AsInteger); // 26
WriteLn(EJ['hobbies'][1].AsString); // CyclingThe TEasyJson class provides a robust set of methods and properties for seamless JSON manipulation.
Create()β Creates an empty JSON object.Create(const AJson: string)β Parses a JSON string.Create(const AJsonValue: TJSONValue)β Wraps an existing JSON value.
Put(AKey: string; AValue: Variant): TEasyJsonβ Adds or updates a key.Put(AIndex: Integer; AValue: Variant): TEasyJsonβ Sets an array element.Add(AKey: string; AValue: Variant): TEasyJsonβ Adds a new key-value pair.AddArray(AKey: string): TEasyJsonβ Adds an empty array.AddObject(AKey: string; AFunc: TFunc<TEasyJson, TEasyJson>): TEasyJsonβ Adds a nested object.ToString(): stringβ Returns a compact JSON string.Format(): stringβ Returns formatted JSON.Count(): Integerβ Returns the number of elements.AsString(): stringβ Converts a JSON value to a string.AsInt32r(): Int32β Converts a JSON value to an int32.AsFloat(): Doubleβ Converts a JSON value to a float.AsBoolean(): Booleanβ Converts a JSON value to a boolean.
Items[AKeyOrIndex: Variant]: TEasyJsonβ Accesses elements by key or index.
See EasyJson.pas for the full documented API.
- π Report Issues: GitHub Issue Tracker
- π¬ Join the Community: Forum | Discord
- π Learn Delphi: Learn Delphi
We welcome contributions to EasyJson! π
- π Report Bugs β Help improve
TEasyJsonby submitting issues. - β¨ Suggest Features β Share ideas to enhance its functionality.
- π§ Submit Pull Requests β Improve the codebase and add features.
EasyJson is distributed under the BSD-3-Clause License, allowing redistribution and modification in both source and binary forms. See the LICENSE for details.
Your support keeps EasyJson evolving! If you find this library useful, please consider sponsoring the project. Every contribution helps drive future enhancements and innovations.
- β Star the repo β Show your appreciation.
- π’ Share with your network β Spread the word.
- π Report bugs β Help improve
TEasyJson. - π§ Submit fixes β Contribute by fixing issues.
- π‘ Suggest features β Help shape its future.
π Every contribution makes a difference β thank you for being part of the journey!
π₯ EasyJson β Effortless JSON Handling for Delphi with Fluent Simplicity.

