Socket
Socket
Sign inDemoInstall

json2php

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json2php - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

75

lib/json2php.js

@@ -1,40 +0,43 @@

// Generated by CoffeeScript 1.4.0
var json2php;
// Generated by CoffeeScript 1.6.3
(function() {
var json2php;
json2php = function(obj) {
var i, result;
switch (Object.prototype.toString.call(obj)) {
case '[object Null]':
result = 'null';
break;
case '[object Undefined]':
result = 'null';
break;
case '[object String]':
result = "'" + obj.replace('\\', '\\\\').replace("'", "\\'") + "'";
break;
case '[object Number]':
result = obj.toString();
break;
case '[object Array]':
result = 'array(' + obj.map(json2php).join(', ') + ')';
break;
case '[object Object]':
result = [];
for (i in obj) {
if (obj.hasOwnProperty(i)) {
result.push(json2php(i) + " => " + json2php(obj[i]));
json2php = function(obj) {
var i, result;
switch (Object.prototype.toString.call(obj)) {
case '[object Null]':
result = 'null';
break;
case '[object Undefined]':
result = 'null';
break;
case '[object String]':
result = "'" + obj.replace(/\\/g, '\\\\').replace(/\'/g, "\\'") + "'";
break;
case '[object Number]':
result = obj.toString();
break;
case '[object Array]':
result = 'array(' + obj.map(json2php).join(', ') + ')';
break;
case '[object Object]':
result = [];
for (i in obj) {
if (obj.hasOwnProperty(i)) {
result.push(json2php(i) + " => " + json2php(obj[i]));
}
}
}
result = "array(" + result.join(", ") + ")";
break;
default:
result = 'null';
result = "array(" + result.join(", ") + ")";
break;
default:
result = 'null';
}
return result;
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = json2php;
global.json2php = json2php;
}
return result;
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = json2php;
global.json2php = json2php;
}
}).call(this);
{
"name": "json2php",
"version": "0.0.3",
"version": "0.0.4",
"description": "JSON to PHP converter",

@@ -21,2 +21,6 @@ "main": "lib/json2php.js",

{
"name": "Daniel Zahariev",
"email": "daniel.zahariev@gmail.com"
},
{
"name": "Bozhidar Dryanovski",

@@ -29,3 +33,3 @@ "email": "bozhidar.dryanovski@gmail.com"

"mocha": "~1.7.4",
"coffee-script": "1.4.0"
"coffee-script": "1.4.0"
},

@@ -32,0 +36,0 @@ "license": "BSD",

@@ -21,3 +21,3 @@ json2php

```javascript
json2php('Hello World!')
json2php('Hello World!')
// => 'Hello World!'

@@ -31,3 +31,3 @@ ```

```javascript
json2php(123)
json2php(123)
// => 123

@@ -47,3 +47,3 @@ ```

```javascript
json2php([1, 2, 3])
json2php([1, 2, 3])
// => array(1, 2, 3)

@@ -55,6 +55,14 @@ ```

```javascript
json2php({a: 1, b: 2, c: 'text'})
json2php({a: 1, b: 2, c: 'text'})
// => array('a' => 1, 'b' => 2, 'c' => 'text')
```
#### Non-valid JSON
```javascript
json2php(new Date())
// => null
```
### Tests

@@ -68,3 +76,3 @@

or use `npm`
or use `npm`

@@ -84,6 +92,10 @@ ```bash

#### 0.0.4
* Fix for single quotes escaping (thanks to @ksky521)
#### 0.0.3
* Fixed the case when non-valid JSON is passed
* Fixing the bug with the object section
#### 0.0.2
#### 0.0.2
* Adding the package.json to Git repository, also package dependancy

@@ -98,5 +110,4 @@ * Changes into the file structure

#### 0.0.1
* Init the project into NPM
* module.exports for Node.js
* Init the project into NPM
* module.exports for Node.js
* Added json2php into the global scope with global.json2php

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc