Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • components
        • events
          • default
      • controllers
      • models
    • components
      • auth
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • exchange
        • rates
          • foxrate
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
      • json
      • modules
      • net
        • http
        • net
          • amazon
            • s3
          • geo
            • ip
      • plugins
      • recaptcha
      • security
      • session
        • cart
      • settingscollection
      • upgrades
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
  • com
    • tecnick
      • tcpdf
        • blesta
          • components
            • invoice
              • templates
                • quickbooks
                  • invoice
                • templates
                  • default
  • Crypt
    • AES
    • DES
    • Hash
    • Random
    • RC4
    • Rijndael
    • RSA
    • TerraDES
  • File
    • ANSI
    • ASN1
    • X509
  • Math
    • BigInteger
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • html
      • xml
    • lib
  • Net
    • SFTP
    • SSH1
    • SSH2
  • None
  • PHP
  • PHPMailer
  • Services
    • JSON
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Services_JSON

Class Services_JSON

Converts to and from JSON format.

Brief example of use:

// create a new instance of Services_JSON
$json = new Services_JSON();

// convert a complexe value to JSON notation, and send it to the browser
$value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
$output = $json->encode($value);

print($output);
// prints: ["foo","bar",[1,2,"baz"],[3,[4]]]

// accept incoming POST data, assumed to be in JSON notation
$input = file_get_contents('php://input', 1000000);
$value = $json->decode($input);
Package: Services\JSON
Copyright: 2005 Michal Migurski
License: http://www.opensource.org/licenses/bsd-license.php
Author: Michal Migurski <mike-json@teczno.com>
Author: Matt Knapp <mdknapp[at]gmail[dot]com>
Author: Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
Located at vendors/json/json.php

Methods summary

public
# Services_JSON( integer $use = 0 )

constructs a new JSON instance

constructs a new JSON instance

Parameters

$use
integer
$use object behavior flags; combine with boolean-OR possible values: - SERVICES_JSON_LOOSE_TYPE: loose typing. "{...}" syntax creates associative arrays instead of objects in decode(). - SERVICES_JSON_SUPPRESS_ERRORS: error suppression. Values which can't be encoded (e.g. resources) appear as NULL instead of throwing errors. By default, a deeply-nested resource will bubble up with an error, so all return values from encode() should be checked with isError()
public string
# utf162utf8( string $utf16 )

convert a string from one UTF-16 char to one UTF-8 char

convert a string from one UTF-16 char to one UTF-8 char

Normally should be handled by mb_convert_encoding, but provides a slower PHP-only method for installations that lack the multibye string extension.

Parameters

$utf16
string
$utf16 UTF-16 character

Returns

string
UTF-8 character
public string
# utf82utf16( string $utf8 )

convert a string from one UTF-8 char to one UTF-16 char

convert a string from one UTF-8 char to one UTF-16 char

Normally should be handled by mb_convert_encoding, but provides a slower PHP-only method for installations that lack the multibye string extension.

Parameters

$utf8
string
$utf8 UTF-8 character

Returns

string
UTF-16 character
public mixed
# encode( mixed $var )

encodes an arbitrary variable into JSON format

encodes an arbitrary variable into JSON format

Parameters

$var
mixed
$var any number, boolean, string, array, or object to be encoded. see argument 1 to Services_JSON() above for array-parsing behavior. if var is a strng, note that encode() always expects it to be in ASCII or UTF-8 format!

Returns

mixed
JSON string representation of input var or an error if a problem occurs
public string
# name_value( string $name, mixed $value )

array-walking function for use in generating JSON-formatted name-value pairs

array-walking function for use in generating JSON-formatted name-value pairs

Parameters

$name
string
$name name of key to use
$value
mixed
$value reference to an array element to be encoded

Returns

string
JSON-formatted name-value pair, like 'name
public string
# reduce_string( mixed $str )

reduce a string by removing leading and trailing comments and whitespace

reduce a string by removing leading and trailing comments and whitespace

Parameters

$str
mixed
$str string string value to strip of comments and whitespace

Returns

string
string value stripped of comments and whitespace
public mixed
# decode( string $str )

decodes a JSON string into appropriate variable

decodes a JSON string into appropriate variable

Parameters

$str
string
$str JSON-formatted string

Returns

mixed
number, boolean, string, array, or object corresponding to given JSON input string. See argument 1 to Services_JSON() above for object-output behavior. Note that decode() always returns strings in ASCII or UTF-8 format!
public
# isError( mixed $data, mixed $code = null )

Magic methods summary

Blesta API documentation generated by ApiGen 2.8.0