2017 © Pedro Peláez
 

library json

Class which provides methods to en- and decode JSON.

image

teacup/json

Class which provides methods to en- and decode JSON.

  • Wednesday, September 24, 2014
  • by daniel.melzer
  • Repository
  • 1 Watchers
  • 1 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 4 % Grown

The README.md

Teacup Json Component Build Status

Usage

use Teacup\Json as Json;

//Encode.
Json::encode($value);

//Encode with options.
Json::encode($value, Json::HEX_AMP);
Json::encode($value, Json::HEX_AMP|Json::HEX_QUOT);

//Decode.
Json::decode($json);

//Get result as array.
Json::decode($json, true);

//Limit depth to 50.
Json::decode($json, false, 50);

Options

  • HEX_TAG: All < and > are converted to \u003C and \u003E. Available since PHP 5.3.0.
  • HEX_AMP: All &s are converted to \u0026. Available since PHP 5.3.0.
  • HEX_APOS: All ' are converted to \u0027. Available since PHP 5.3.0.
  • HEX_QUOT: All " are converted to \u0022. Available since PHP 5.3.0.
  • FORCE_OBJECT: Outputs an object rather than an array when a non-associative array is used. Especially useful when the recipient of the output is expecting an object and the array is empty.
  • NUMERIC_CHECK: Encodes numeric strings as numbers. Available since PHP 5.3.3.
  • BIGINT_AS_STRING: Encodes large integers as their original string value. Available since PHP 5.4.0.
  • JSON_PRETTY_PRINT: Use whitespace in returned data to format it. Available since PHP 5.4.0.
  • JSON_UNESCAPED_SLASHES: Don't escape /. Available since PHP 5.4.0.
  • JSON_UNESCAPED_UNICODE: Encode multibyte Unicode characters literally (default is to escape as \uXXXX). Available since PHP 5.4.0.

Errors

Json::encode() and Json::decode() are throwing RuntimeExceptions if an error occures., (*1)

The Versions

24/09 2014

dev-master

9999999-dev

Class which provides methods to en- and decode JSON.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

json

24/09 2014

0.2.0

0.2.0.0

Class which provides methods to en- and decode JSON.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

json

24/09 2014

dev-dev

dev-dev

Class which provides methods to en- and decode JSON.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

json