jp-freeze
v0.3.1
Published
JSON - PHP serializer/unserializer
Downloads
3
Maintainers
Readme
jp-freeze
JSON - PHP serailizer/unserializer
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.