Comparing version 0.0.2 to 0.0.3
@@ -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.3", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38
96
5215