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.2 to 0.0.3-r

68

lib/json2php.js

@@ -1,34 +0,40 @@

function json2php(obj) {
var result = '', i;
switch (Object.prototype.toString.call(obj)) {
case '[object Null]':
case '[object Undefined]':
result = 'null';
break;
case '[object String]':
result = "'" + obj.replace('\\', '\\\\').replace("'", "\\'") + "'";
break;
case '[object Number]':
result = '' + obj;
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;
}
return result;
}
// Generated by CoffeeScript 1.4.0
var json2php;
if (typeof module !== 'undefined' && module.exports)
{
module.exports = 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]));
}
}
result = "array(" + result.join(", ") + ")";
break;
default:
result = 'null';
}
return result;
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = json2php;
global.json2php = json2php;
}
{
"name": "json2php",
"version": "0.0.2",
"version": "0.0.3r",
"description": "JSON to PHP converter",

@@ -5,0 +5,0 @@ "main": "lib/json2php.js",

@@ -74,4 +74,2 @@ json2php

This is not finished yet. There is a bug into the Object sections.
```bash

@@ -82,2 +80,5 @@ $ coffee -c -b -o ./lib src/json2php.coffee

#### 0.0.3
* Fixing the bug with the object section
#### 0.0.2

@@ -84,0 +85,0 @@ * Adding the package.json to Git repository, also package dependancy

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