Login   Register  
PHP Classes
elePHPant
Icontem

File: test/DataProcess.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Dmitri Russu  >  PHP Reduce JSON  >  test/DataProcess.php  >  Download  
File: test/DataProcess.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Reduce JSON
Compress JSON data using the reduced JSON format
Author: By
Last change:
Date: 2013-04-07 04:17
Size: 889 bytes
 

Contents

Class file image Download
<?php
/**
 * Created by Dumitru Russu.
 * User: developer
 * Date: 4/1/13
 * Time: 10:58 PM
 * To change this template use File | Settings | File Templates.
 */
require_once '../rjson.lib.php';


class 
DataProcess {
    public static function 
getData() {
        
$data file_get_contents('init_array.txt');
        return 
RJson::pack(unserialize($data), true);
    }

    public static function 
saveData($data) {
        
$compactData RJson::unpack($data);
        return 
file_put_contents('final_array_unpacked.txt'serialize($compactData));
    }
}

//Call function
if(isset($_GET['action'])) {
    
call_user_func($_GET['action'], (isset($_POST['pack_data']) ? $_POST['pack_data'] : null));
}

function 
get_data() {
    print 
DataProcess::getData();
    exit;
}

function 
save_data($data) {
    if (
DataProcess::saveData($data)) {
        print 
'With Success data unpack and saved!';
        exit;
    }
    print 
"Data can't unpack save!";
    exit;
}