Skip to content

Releases: ademchaoua/JSONManager

v1.0.1 Release - JSONManager Class with Static Methods

17 Jun 03:54
Compare
Choose a tag to compare

Summary

This release introduces the JSONManager class, a PHP utility for managing JSON files with comprehensive CRUD operations, sorting, pagination, merging, backup, and restore functionalities.

Key Features

  • Static Methods: All methods are now static for easier usage without instantiation.
  • Create, Update, Find, Delete: Comprehensive operations for manipulating JSON data.
  • Count, Sort, Paginate: Utilities to manage and navigate through JSON data efficiently.
  • Merge: Combine data from other JSON files or arrays seamlessly.
  • Backup and Restore: Safeguard data integrity with backup and restore capabilities.

Usage Examples

Create a New Object

<?php
require_once 'JsonManager.php'; // Assuming your class file is named JsonManager.php

$path = 'data.json';
$newObject = [
    'id' => 1,
    'name' => 'John Doe',
    'age' => 30,
    'city' => 'New York'
];

try {
    // Save the new object under 'users' without updating existing data
    JsonManager::save($path, $newObject, false, 'users');
    echo "New object saved successfully!";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
?>

Update an Existing Object

<?php
require_once 'JsonManager.php'; // Assuming your class file is named JsonManager.php

$path = 'data.json';
$updatedObject = [
    'id' => 1,
    'name' => 'John Doe',
    'age' => 31,
    'city' => 'Los Angeles'
];

try {
    // Update the existing object where 'id' equals 1 under 'users'
    JsonManager::save($path, $updatedObject, true, 'users', 'id', 1);
    echo "Object with ID 1 updated successfully!";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
?>

Additional Notes

  • This release streamlines JSON data management by offering static methods for direct access and usability.
  • Future enhancements may include advanced querying and performance optimizations.

Full Changelog: GitHub Commit History

Release v1.0.0 - Initial Release

15 Jun 08:19
Compare
Choose a tag to compare

Summary

This release introduces the JSONManager class, a PHP utility for managing JSON files with comprehensive CRUD operations, sorting, pagination, merging, backup, and restore functionalities.

Key Features

  • Create: Easily create new objects in JSON files.
  • Update: Update existing objects based on key-value pairs.
  • Find and Delete: Efficient methods to find and delete objects by specified criteria.
  • Count and Sort: Count objects and sort them based on specified keys.
  • Pagination: Paginate through large datasets for easier handling.
  • Merge: Merge data from other JSON files or arrays seamlessly.
  • Backup and Restore: Backup and restore JSON files for data integrity.

Usage Examples

// Example usage of JSONManager class to create a new object
$path = 'data.json';
$newObject = ['id' => 1, 'name' => 'John Doe', 'age' => 30, 'city' => 'New York'];
$jsonManager = new JSONManager($path, $newObject, true, 'users');
$jsonManager->save();

Additional Notes

  • This release focuses on providing foundational functionalities for managing JSON data in PHP applications.
  • Future releases may include enhancements such as advanced querying capabilities and performance optimizations.

Full Changelog: https://github.com/ademchaoua/JSONManager/commits/v1.0.0