![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
json2php
Advanced tools
Readme
To install json2php you could clone the project from Github or use NPM to install it.
$ npm install json2php
Convert JavaScript object/array/string/number/boolean to string that is the corresponding PHP representation.
When the content is just a string the output will be the same string.
s = json2php('Hello World!')
// => s = 'Hello World!'
Numbers are the same.
s = json2php(123)
// => s = '123'
s = json2php( true )
// => s = 'true'
null
and undefined
are returned as null
s = json2php(undefined)
// => s = 'null'
s = json2php([1, 2, 3])
// => s = 'array(1, 2, 3)'
s = json2php({a: 1, b: 2, c: 'text', false: true, undefined: null})
// => s = "array('a' => 1, 'b' => 2, 'c' => 'text', 'false': true, 'undefined': null)"
s = json2php(new Date())
// => s = "null"
Create custom 'printers' with json2php.make
:
const printer = json2php.make({linebreak:'\n', indent:'\t', shortArraySyntax: true})
printer({one: 3, two: 20, three: [9, 3, 2]})
/* result:.
[
'one' => 3,
'two' => 20,
'set' => [
9,
3,
2
]
]
*/
To compress the output (e.g. to make the resulting PHP as small as possible), use shortArraySyntax
with stripSpaces
:
const printer = json2php.make({shortArraySyntax: true, stripSpaces: true})
printer({
arr: [1, 2, 3, 4, 5, {foo: 'surprise!'}],
obj: {
arr: [{foo: 'bar', bar: 'baz', arr2: [1, 2]}]
}
})
// result:
// ['arr'=>[1,2,3,4,5,['foo'=>'surprise!']],'obj'=>['arr'=>[['foo'=>'bar','bar'=>'baz','arr2'=>[1,2]]]],'test'=>'str']
To run test we use mocha
framework.
$ npm test
But in any case you will depend on coffee-script
$ npm run build
stripSpaces
to pretty print options (thanks to @noahtallen)shortArraySyntax
to pretty print optionsjson2php.make
(thanks to @stokesman)test
test
, src
, lib
directoryFAQs
JSON to PHP converter
The npm package json2php receives a total of 71,482 weekly downloads. As such, json2php popularity was classified as popular.
We found that json2php demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.