jp-freeze

0.3.1 • Public • Published

jp-freeze

JSON - PHP serailizer/unserializer

Latest Version on Packagist Build Status No dependencies MIT License

Description

This package provides the functionality of unserialization of data encoded by the PHP pj-freeze package.

Usage

Example: usage in Node.js

var fs = require('fs');
var JpFreeze = require('jp-freeze');
 
var json = fs.readFileSync('test.json').toString();
var serialized = JSON.parse(json);
 
var obj = new JpFreeze().unserialize(serialized);
 
console.log(obj);

Example: usage in browser

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JpFreeze Test</title>
</head>
<body>
 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="bower_components/jp-freeze/dist/jp-freeze.js"></script>
<script type="text/javascript">
    $.ajax({
        url: 'https://localhost/get-user.php?id=1234',
        dataType: 'json',
        success: function(data) {
            var user = new JpFreeze().unserialize(data);
            console.log(user.firstName);
        }
    });
</script> 
 
</body>
</html>

Installation

NPM

npm install jp-freeze

Bower

bower install jp-freeze

Limitations

So far only the unserialization is implemented in JavaScript. The serialization is only available through the corresponding PHP package.

Package Sidebar

Install

npm i jp-freeze

Weekly Downloads

0

Version

0.3.1

License

MIT

Last publish

Collaborators

  • maciej-sz