Skip to content

Class to open, modify and write json objects in files

License

Notifications You must be signed in to change notification settings

Dayjo/php-json-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP JSON Handler

Class to open, modify and write json objects in files.

Installation (without composer)

Just include the json.php file.

require 'src/json.php';

Alternatively, namespace and autoload it.

Installation (with composer)

composer require dayjo/php-json-handler

Then use;

use Dayjo\JSON;

Usage

Basic usage includes auto saving, so you just modify the data and it saves!

<?php
$JSON = new JSON('config.json');
$config =& $JSON->data; // You could just do $config->data->name = ...

$config->name = 'dayjo';
$config->last_edited = time();

Options

Auto Save

The optional second parameter to the JSON class allows you to turn off auto save, and make it so you have to run the save function manually for instance;

<?php
$JSON = new JSON('config.json', false);
$config =& $JSON->data;

$config->name = 'dayjo';

$JSON->save();

About

Class to open, modify and write json objects in files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages