json_builder_pro 1.1.1 copy "json_builder_pro: ^1.1.1" to clipboard
json_builder_pro: ^1.1.1 copied to clipboard

A Dart package for programmatically constructing and manipulating complex JSON structures.

JSON Builder Pro #

pub version license stable

Status: This package is considered stable and ready for production use.

Programmatic JSON Tree Construction for Dart & Flutter #

json_builder_pro is a Dart package for programmatically constructing and manipulating complex JSON structures. It provides a tree-based data model, enabling developers to build, traverse, and modify JSON objects and arrays with precision and control.

Ideal for applications that need to generate or manipulate complex JSON, json_builder_pro streamlines the process of creating syntactically correct and semantically rich JSON output.

Key Features #

  • 🌳 Hierarchical Tree-Based Model: Represents JSON structures as a logical, navigable tree, where nodes encapsulate structural elements (objects and arrays) and leaves represent atomic components (strings, numbers, booleans, and null).
  • 🚀 Pure Dart & Cross-Platform Compatibility: Developed entirely in Dart, ensuring seamless integration and consistent performance across all Dart and Flutter supported platforms (Web, Mobile, Desktop).

Getting Started #

Integrate json_builder_pro into your Dart or Flutter project by adding it to your pubspec.yaml:

dependencies:
  json_builder_pro: ^1.0.0 # Always use the latest stable version

Then, execute flutter pub get or dart pub get to fetch the package.

Import the library in your Dart code:

import 'package:json_builder_pro/json_builder_pro.dart';

Usage Examples #

Building a Simple JSON Object #

import 'package:json_builder_pro/json_builder_pro.dart';

void main() {
  final tree = JSONTree();

  final object = JSONObjectNode();
  object.addValue('name', JSONStringLeaf('John Doe'));
  object.addValue('age', JSONNumberLeaf(30));
  object.addValue('isStudent', JSONBooleanLeaf(false));
  object.addValue('courses', JSONNullLeaf());

  tree.root = object;

  print(tree.toJSONString());
  // Output:
  // {
  //   "name": "John Doe",
  //   "age": 30,
  //   "isStudent": false,
  //   "courses": null
  // }
}

Building a Nested JSON Object #

import 'package:json_builder_pro/json_builder_pro.dart';

void main() {
  final tree = JSONTree();

  final object = JSONObjectNode();
  object.addValue('name', JSONStringLeaf('John Doe'));

  final address = JSONObjectNode();
  address.addValue('street', JSONStringLeaf('123 Main St'));
  address.addValue('city', JSONStringLeaf('Anytown'));
  object.addValue('address', address);

  tree.root = object;

  print(tree.toJSONString());
  // Output:
  // {
  //   "name": "John Doe",
  //   "address": {
  //     "street": "123 Main St",
  //     "city": "Anytown"
  //   }
  // }
}

Contributing #

We welcome contributions from the community! If you encounter any bugs, have feature requests, or wish to contribute code, please open an issue or a pull request.

License #

This package is distributed under the MIT License.

1
likes
150
points
22
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Dart package for programmatically constructing and manipulating complex JSON structures.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on json_builder_pro