Comparing version
@@ -5,4 +5,6 @@ // Generated by CoffeeScript 2.7.0 | ||
make = function({linebreak = '', indent = ''} = {}) { | ||
var nest, transform; | ||
make = function({linebreak = '', indent = '', shortArraySyntax = false} = {}) { | ||
var arrClose, arrOpen, nest, transform; | ||
arrOpen = shortArraySyntax ? '[' : 'array('; | ||
arrClose = shortArraySyntax ? ']' : ')'; | ||
nest = { | ||
@@ -48,3 +50,3 @@ '[object Array]': function(obj, parentIndent) { | ||
items = nest[objType](obj, nestIndent); | ||
result = `array(${linebreak + nestIndent}${items.join(',' + (linebreak === '' ? ' ' : linebreak + nestIndent))}${linebreak + parentIndent})`; | ||
result = `${arrOpen}${linebreak + nestIndent}${items.join(',' + (linebreak === '' ? ' ' : linebreak + nestIndent))}${linebreak + parentIndent}${arrClose}`; | ||
break; | ||
@@ -64,4 +66,4 @@ default: | ||
module.exports = json2php; | ||
// Not that good but usefull | ||
// Not that good but useful | ||
global.json2php = json2php; | ||
} |
{ | ||
"name": "json2php", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "JSON to PHP converter", | ||
@@ -5,0 +5,0 @@ "main": "lib/json2php.js", |
@@ -75,15 +75,15 @@ json2php | ||
```javascript | ||
const printer = json2php.make({linebreak:'\n', indent:'\t'}) | ||
const printer = json2php.make({linebreak:'\n', indent:'\t', shortArraySyntax: true}) | ||
printer({one: 3, two: 20, three: [9, 3, 2]}) | ||
/* result:. | ||
array( | ||
[ | ||
'one' => 3, | ||
'two' => 20, | ||
'set' => array( | ||
'set' => [ | ||
9, | ||
3, | ||
2 | ||
) | ||
) | ||
] | ||
] | ||
*/ | ||
@@ -112,2 +112,5 @@ ``` | ||
#### 0.0.7 | ||
* Add `shortArraySyntax` to pretty print options | ||
#### 0.0.6 | ||
@@ -114,0 +117,0 @@ * Add pretty print capability via `json2php.make` (thanks to @stokesman) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
9482
8.49%62
3.33%141
2.17%