PHP code example of harshilkaneria / jsonbash

1. Go to this page and download the library: Download harshilkaneria/jsonbash library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

harshilkaneria / jsonbash example snippets




n\Bash\JsonBash;


// Case 1 Basic

$data = array();
$data['id']= '1';
$data['name']=  'harshil';
$data['lastname']=  'kaneria';

$string = new JsonBash();
echo $string->jsonmanager(true,"Data Fetch Successfully",$data);

// Result of Case 1

{
	status : true,
	message : "Data Fetch Sucessfully"
	data : {
		id:'1',
		name: 'harshil',
		lastname: 'kaneria'
	}
}


// Case 2 Remove Predefind Fileds


$data = array();
$data['id']= '1';
$data['name']=  'harshil';
$data['lastname']=  'kaneria';

$string = new JsonBash();
echo $string->jsonmanager(false,null,$data);

// Result of Case 2

{
	status :false,
	data : {
		id:'1',
		name: 'harshil',
		lastname: 'kaneria'
	}
}


// Case 3 Add Custom Fileds


$data = array();
$data['id']= '1';
$data['name']=  'harshil';
$data['lastname']=  'kaneria';

$code = array();
$code['statuscode'] = "200";

$string = new JsonBash();
echo $string->jsonmanager(true,null,$data,$code);

// Result of Case 3

{
	status : true,
	data : {
		id:'1',
		name: 'harshil',
		lastname: 'kaneria'
	},
	statuscode :'200'
}